This is supposed to change the color of the HP Gui depending on a player's HP. The problem is that the color always stays as yellow. And I was supposed to add a wait() somewhere, but I forgot. This script is a regular script parented to the GUI.
while true do if script.Parent.Parent.Parent.Character.Humanoid.Health > 50 then script.Parent.Frame.BackgroundColor3 = Color3.new(85,225,0) -- I think that was for green. If not, please fix it. elseif script.Parent.Parent.Parent.Character.Humanoid.Health < 50 and script.Parent.Parent.Parent.Character.Humanoid.Health > 20 then -- I just added the "and" to this, not in the original script, so I am not sure if it will fix my script or not. script.Parent.Frame.BackgroundColor3 = Color3.new() -- I forgot what yellow was c: elseif script.Parent.Parent.Parent.Character.Humanoid.Health < 20 then script.Parent.Frame.BackgroundColor3 = Color3.new(255,0,0) -- I think this was red. If not, please fix it. end
First thing is your game will crash if you don't put a wait in your while loop like this
while true do wait() --code end
or
while wait() do --code end
The reason it's yellow is because Color3.new() goes from 0 to 1. 0 representing 0 out of 225, and 1 representing 225 out of 225. If you want it green do this:
script.Parent.Frame.BackgroundColor3 = Color3.new(0,1,0)
For Color3.new() if you wanted yellow, do this:
script.Parent.Frame.BackgroundColor3 = Color3.new(1,1,0)
And for red all you'd have to do is:
script.Parent.Frame.BackgroundColor3 = Color3.new(1,0,0)