I Just did something like this,
part.Touched:Connect(function(p)
if p.Parent.FindFirstChild == ("Humanoid") then
local plr = workspace[p.Parent.Name]
wait(0.5)
plr.Humanoid:TakeDamage(20)
wait(0.1)
part:Destroy()
end
end)
end)
but i dont know what did i do wrong can someone help please?
script.Parent.Activated:Connect(function()
local character = script.Parent.Parent
local Humanoid = character:WaitForChild('Humanoid')
local torso = character:WaitForChild('HumanoidRootPart')
local part = Instance.new("Part",game.Workspace)
part.Size = Vector3.new(7.8, 3.6, 4.2)
part.CanCollide = false
part.Anchored = true
part.CFrame = torso.CFrame+(torso.CFrame.lookVector*3)
part.Touched:Connect(function(p)
if p.Parent.FindFirstChild == ("Humanoid") then
local plr = workspace[p.Parent.Name]
wait(0.5)
plr.humanoid.Health = plr.humanoid.Health - 20
wait(0.1)
part:Destroy()
end
end)
end)
Full code is this, other things are working but that part.Touched is broken

3 comments
Its worked but its killing instantly, i want do to once 20 when u Activated the tool
And the part is killing me too i just want to kill custom models like zombies and not players. Should i change Humanoid name or something what i have to do for it ?
Sorry, I am late. You should just make sure that it doesn't kill Players