How to make a stamina bar change colors depending on how much stamina the player has

I wanna make my stamina bar adjust color from blue to red depending on how much stamina the player has. I know I can use Color3.fromHSV but I don’t know how to do it. Can anyone help me?

You could alternatively just use the interpolation function :Lerp which is simpler to use

local blue =, 0, 1)
local red =

local clr = red:Lerp(blue, stamina) --stamina being a 0 to 1 value, 1 being max stamina
1 Like

Try using Color3:Lerp(). This function smoothly interpolates the two colors:

local Blue =,0,1)
local Red =,0,0)

print(Blue:Lerp(Red,0.5)) -- This color would be halfway between red and blue
print(Blue:Lerp(Red,0)) -- This would be just blue, since you're translating it 0%
print(Blue:Lerp(Red,1)) -- This would be fully red, since you're translating it to red by 100%
1 Like

I tried this and it didn’t work, it just flashes the color bar

Basically it keeps flashing teal and white

Yea it would be really helpful if you showed me the script

The fraction alpha argument (2nd argument) to Color3:Lerp should be a value between 0 and 1 representing the percentage of stamina remaining, i.e; 50% stamina would be represented by a fraction alpha of 0.5., 0, 0):Lerp(, 1, 0), CurrentStamina/MaxStamina)
Something like this.

Ok sure

local blue =, 0.572549, 1); -- light blue
local red =, 0, 0); -- dark red

	tweenservice:Create(staminabar,, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Size = / 100, -5, 1, -5)}):Play();
	staminabar.BackgroundColor3 = red:Lerp(blue, stamina.Value)

And what is stamina.Value? I believe I mentioned in my first post that the interpolation alpha must be a 0 to 1 number
@Forummer explained above in greater detail

stamina.Value should be divided by the maximum stamina value.


Oh okay, I will do that

(char limit)

It works now, thank you so much