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 :
1 | script.Parent.ClickDetector.MouseClick:Connect( function (p) |
2 | p.Health = 0 |
3 | 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.
1 | script.Parent.ClickDetector.MouseClick:Connect( function (p) |
2 | p.Character.Humanoid.Health = 0 -- getting the character, the humanoid is in there. |
3 | end ) |