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

How do you script the value of Humanoid Health?

Asked by 6 years ago

For example, if the humanoid health's value is z, then something happens. This is my code: if health = 0 then this code doesn't work. How do I make this code work?

2 answers

Log in to vote
0
Answered by
oSyM8V3N 429 Moderation Voter
6 years ago

When your using conditional statements, only == is valid. You would most likely only use = if your changing the transparency or for ex: Thing.Transparency = Thing.Transparency - num.

This is the correct way to use the if statement with the humanoids health :

local p = game.Players.LocalPlayer
z = 0

if p.Character.Humanoid.Health == z then
print("humanoids health is at 0")

end
Ad
Log in to vote
0
Answered by
UgOsMiLy 1074 Moderation Voter
6 years ago

Try this.

local z = 0

if humanoid.Health == z then
    -- code
end

You use == for equals to and = for assigning values.

0
Basically the same thing what i said, and you didn't defined humanoid oSyM8V3N 429 — 6y
0
Sorry, didn't see it when I clicked on the page. UgOsMiLy 1074 — 6y
0
I didn't mena to approach you in a negative way. Just wanted to let you know what was wrong oSyM8V3N 429 — 6y

Answer this question