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

problem with color3?

Asked by
theCJarmy7 1293 Moderation Voter
8 years ago
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

Log in to vote
1
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

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)
0
i make so many of these tiny mistakes... thank you theCJarmy7 1293 — 8y
0
No problem. I recommend reading the Scripting Book, by the way: http://wiki.roblox.com/index.php?title=Scripting_Book Pyrondon 2089 — 8y
Ad

Answer this question