I am trying to make a script that functions when the part is clicked.
script.Parent.ClickDetector.MouseClick:connect(function(plr)
local name = script.Parent.Parent.Name
name = "Hey,"..plr.Name..". Yeah you. I'm gonna punch you for clicking me!"
wait(5)
plr.Humanoid:TakeDamage(25)
name = "Hmm, that didn't feel good enough. LET MEH PUNCH YOU HARDER!"..plr.Name
wait(5)
plr.Humanoid:TakeDamage(50)
name = "Still not dead. TIME FOR FUS RO DAH!!!"
wait(5)
plr.Humanoid:TakeDamage(1337)
name = "That felt better."
wait(5)
name = "Please don't click me!"
end)
It doesn't work, and it says in the output that there is no humanoid. Help?

1 comment
First, wait is not a valid method of a model or Humanoid. Second waiting for the character/humanoid does not make sense here as it would kill them after they respawn. Third checking for the Humanoid without FindFirstChild will just cause an error.