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

The numbers getting crazy How do I fix it?

Asked by 6 years ago

I made a custom hp bar, And the color supposed to be between red and green but the color keeps going to numbers like 69000 what is going on???

01x = 314
02y = 40
03 
04 
05game.Players.PlayerAdded:Connect(function(plr)
06    --//values\\
07    local gui = plr.PlayerGui:WaitForChild("Health", 99)
08    local hbar = gui:WaitForChild("Bar", 99)
09    local playerhp = gui:WaitForChild("PlayerHealth", 99)
10    local maxhealth = gui:WaitForChild("MaxHealth", 99)
11    local persec = gui:WaitForChild("PerSecond", 99)
12    local percent = playerhp.Value / maxhealth.Value
13    --//connect\\
14    playerhp.Changed:connect(function()
15    playerhp = gui:WaitForChild("PlayerHealth", 99)
View all 27 lines...

please help!

0
playerhp is an objectvalue? and your equation is wrong, it should be: local green = 1 * percent INOOBE_YT 387 — 6y

1 answer

Log in to vote
0
Answered by
Rare_tendo 3000 Moderation Voter Community Moderator
6 years ago

Because Color3.new accepts numbers from 0 - 1 and you're passing higher numbers.

1local green = percent
2local red = 1 - percent
3 
4hbar.BackgroundColor3 = Color3.new(red, green, 0)
Ad

Answer this question