Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

OnTouch won't kill humanoid?

Asked by
car9 20
10 years ago

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

Log in to vote
1
Answered by
Sublimus 992 Moderation Voter
10 years ago

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

It should be:

if hit.Parent:findFirstChild("Humanoid") then
0
Thanks. car9 20 — 10y
Ad

Answer this question