I made a Stamina bar that changes the color of the bar from red to green when it’s half way gone, but it never changes back to green and i’m confused on what’s a better way to format this
local HighStamColor = Color3.fromRGB(92, 193, 69)
local LowStamColor = Color3.fromRGB(191, 60, 60)
local tweenInfo = TweenInfo.new(1)
local tween = TweenService:Create(players.LocalPlayer.PlayerGui.Main.Stanima.Stanima, tweenInfo, {BackgroundColor3=HighStamColor})
local tween2 = TweenService:Create(players.LocalPlayer.PlayerGui.Main.Stanima.Stanima, tweenInfo, {BackgroundColor3=LowStamColor})
replicatedStorage.RemoteEvents.StaminaUpdate.OnClientEvent:Connect(function(stamina, maxStamina)
print(players.LocalPlayer.PlayerGui.Main.Stanima.Stanima.BackgroundColor3)
players.LocalPlayer.PlayerGui.Main.Stanima.Stanima.Size = UDim2.new((stamina / maxStamina),0,0.9,0)
if (stamina / maxStamina) <= 0.5 then
if players.LocalPlayer.PlayerGui.Main.Stanima.Stanima.BackgroundColor3 == HighStamColor then
tween2:Play()
print"red"
else
end
else
if players.LocalPlayer.PlayerGui.Main.Stanima.Stanima.BackgroundColor3 == LowStamColor then
tween:Play()
print"green"
else
end
end
end)