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

How do you script the value of Humanoid Health?

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

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

Try this.

local z = 0

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

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

3 comments

0

Basically the same thing what i said, and you didn't defined humanoid

0

Sorry, didn't see it when I clicked on the page.

0

I didn't mena to approach you in a negative way. Just wanted to let you know what was wrong

This discussion is preserved as it was. New answers, comments, and votes are closed.