I created a Tool with only a brick and a script in it. I created a humanoid with only a part named Head in it. When the Tool touches the Humanoid part, the humanoid should lose 10 health. But nothing happens.
The script:
script.Parent.Handle.Touched:connect(function(part) part.Parent:FindFirstChild("Humanoid") if found then Humanoid:TakeDamage(10) end end)
What's wrong?
I'm not sure what you mean by if found then
, because that wouldn't work. Also you didn't define Humanoid
. You could simply do it like this:
script.Parent.Handle.Touched:connect(function(hit) local hum = hit.Parent:FindFirstChild("Humanoid") if hum ~= nil then hum:TakeDamage(10) end end)