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

problem with color3?

if human.Health > human.Health * .5 then
	script.Parent.Parent.BackgroundColor3 = Color3.new(32/255, 204/255, 6/255)
elseif human.Health <= human.Health * .5 and human.Health > human.Health/4 then
	script.Parent.Parent.BackgroundColor3 = Color3.new(251/255, 255/255, 11/255)
elseif human.Health <= human.Health/4 then
	script.Parent.Parent.BackgroundColor3 = Color3.new(255/255, 0/255, 0/255)
end
end)

where human is game.Players.LocalPlayer.Character.Humanoid. and this is connected to a while loop, but its not shown. it never changes color, and there isnt anything in the output.

1 answer

✓ Accepted answer

The first if statement will always be true, unless it's 0. I assume you meant to use MaxHealth.

if human.Health > human.MaxHealth * .5 then
	script.Parent.Parent.BackgroundColor3 = Color3.new(32/255, 204/255, 6/255)
elseif human.Health <= human.MaxHealth * .5 and human.Health > human.MaxHealth/4 then
	script.Parent.Parent.BackgroundColor3 = Color3.new(251/255, 255/255, 11/255)
elseif human.Health <= human.MaxHealth/4 then
	script.Parent.Parent.BackgroundColor3 = Color3.new(255/255, 0/255, 0/255)
end
end)

2 comments

0

i make so many of these tiny mistakes... thank you

0

No problem. I recommend reading the Scripting Book, by the way: http://wiki.roblox.com/index.php?title=Scripting_Book

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