Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

OnTouch won't kill humanoid?

I want it so when you touch a part it kills you, and I can't seem to find my mistake:

script.Parent.Touched:connect(function(hit)
	if hit.Parent:findFirstChild(Humanoid) then
		hit.Parent.Humanoid.Health = 0
	end
end)

1 answer

✓ Accepted answer

The findFirstChild function requires a string, as it finds by an instance's name.

It should be:

if hit.Parent:findFirstChild("Humanoid") then

1 comment

0

Thanks.

This discussion is preserved as it was. New answers, comments, and votes are closed.