Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to die by using a clickdetector?

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)

2 comments

1

p.Character.Humanoid.Health

0

Health is a property of the Humanoid and not the player.

1 answer

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)

7 comments

0

LOL just realised Phlegethon5778 commented before me

0

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.

0

p cannot be a part.

0

can parts click things?

0

^ confused it with a .Touched event woops! Then I guess you are correct.

0

Haha. made my day

0

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.