local Tool = script.Parent
local Handle = Tool.Handle
local db = true
Tool.Activated:Connect(function()
local Hitbox = Instance.new("Part")
Hitbox.Parent = workspace
Hitbox.Position = Handle.Position
Hitbox.Orientation = Handle.Orientation
Hitbox.Size = Vector3.new(4, 4, 4)
Hitbox.Transparency = 0.5
Hitbox.Anchored = true
Hitbox.CanCollide = false
Hitbox.Touched:Connect(function(Hit)
if db and Hit.Parent:WaitForChild("Humanoid") then
db = false
Hit.Parent.Humanoid:TakeDamage(10)
Hitbox:Destroy()
task.wait(0.5)
db = true
end
task.wait(0.1)
Hitbox:Destroy()
end)
end)```
#I don't care about optimisation how do I make this not hit the player
1 messages · Page 1 of 1 (latest)
just check if the hit isn't apart of the player using the tool
how do I implement that?
just add "not playervariablehere.Character:FindFirstChild(hit)" to your if statement
it came out as argument #1 expects a string, but Instance was passed
Is it better to do getpartsinsidepart instead of .touched for hitboxes?
just add a lil
local players = game:GetService("Players")
if Hit.Parent = Players.LocalPlayer then
return
end