it says Health is not a valid member of Player whenever i click a brick which is supposed to kill you instantly whenever you click on it , heres the script :
script.Parent.ClickDetector.MouseClick:Connect(function(p)
p.Health = 0
end)
it says Health is not a valid member of Player whenever i click a brick which is supposed to kill you instantly whenever you click on it , heres the script :
script.Parent.ClickDetector.MouseClick:Connect(function(p)
p.Health = 0
end)
The Health property is a property of the Humanoid, not the Player instance itself. The humanoid is inside of the player's character, so you can access the Character property and get the humanoid from there.
script.Parent.ClickDetector.MouseClick:Connect(function(p)
p.Character.Humanoid.Health = 0 -- getting the character, the humanoid is in there.
end)
LOL just realised Phlegethon5778 commented before me
Not a good way of doing that, would recommend doing some checks before doing that so if p is a part or something else it won't error but instead do nothing.
p cannot be a part.
can parts click things?
^ confused it with a .Touched event woops! Then I guess you are correct.
Haha. made my day
instead of setting the Humanoid's health to 0 you can do p.Character:BreakJoints()
This discussion is preserved as it was. New answers, comments, and votes are closed.
2 comments
p.Character.Humanoid.Health
Health is a property of the Humanoid and not the player.