Hello everyone who reads this question, I want to make a health bar for my game, however, it doesn't change the color of the bar when the health is at a certain point
The hierarchy is game>StarterGui/PlayerGui>HealthUI>HealthBar>GetPlayerHealth[The script is a local script] Plus I also noticed another thing, it returns a float(A decimal number but not waaaaaaay to exact), I have tried math.floor()(math.floor rounds down a number) and math.ceil()(math.ceil rounds up a number) but it doesn't work(I have deleted that piece of code)
-- Variables --
local starterUI = game:GetService("StarterGui")
local player = game.Players.LocalPlayer
local character = player.Character
local hum = character:FindFirstChild("Humanoid")
local bar = script.Parent
-- Loops --
while wait() do
bar.Text = hum.Health .. " / " .. hum.MaxHealth
end
while wait() and (hum.Health <= 70 and hum.Health >= 50) do
bar.BackgroundColor3 = Color3.fromRGB(234, 255, 41) -- This is the same thing as Color3.new(234/255,255/255,41/255) for the people who didn't know that
end
while wait() and (hum.Health <= 50 and hum.Health >= 30)do
bar.BackgroundColor3 = Color3.fromRGB(207, 178, 70)
end
while wait() and (hum.Health <= 30 and hum.Health >= 0)do
bar.BackgroundColor3 = Color3.fromRGB(207, 9, 9)
end
It would be much appreciated if you answer this question

2 comments
I highly suggest taking a look at my answer. Otherwise, congratulations on getting your script to work the way you want it.
Time for UDim2