I made this extremely simple script, but for some reason it decides not to work.
Here is the script:
function onTouched(part, plr)
local h = part.Parent:findFirstChild("Humanoid")
if h~=nil then
h.Health = 0
print(plr.Name .. " has died!") --this is line 5
end
end
script.Parent.Touched:connect(onTouched)
Here is the error I get:
Workspace.Kill brick.Code:5: attempt to index local 'plr' (a nil value)
This has never been a problem when I use multiple arguments in a function. Can someone help?

1 comment
Explain your answers.