Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to die by using a clickdetector?

Asked by 5 years ago
Edited 5 years ago

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)
1
p.Character.Humanoid.Health User#21908 42 — 5y
0
Health is a property of the Humanoid and not the player. User#21908 42 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

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)
0
LOL just realised Phlegethon5778 commented before me User#24403 69 — 5y
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. valchip 789 — 5y
0
p cannot be a part. User#21908 42 — 5y
0
can parts click things? User#21908 42 — 5y
View all comments (3 more)
0
^ confused it with a .Touched event woops! Then I guess you are correct. valchip 789 — 5y
0
Haha. made my day Oficcer_F 207 — 5y
0
instead of setting the Humanoid's health to 0 you can do p.Character:BreakJoints() hellmatic 1523 — 5y
Ad

Answer this question