I currently have a functioning stamina bar, however the way it progresses isn’t exactly what I wanted because the math is off, the stamina bar goes empty when the stamina is full, and the bar goes filled when stamina is empty. I wanted the bar to be full when stamina is full, and empty when stamina is empty.
(Streamable video since I can’t upload video directly in DevForum for some reason, it takes too long to process it.) https://streamable.com/4x4why
-- Placeholder variables
local PhysicalBar = the surfacegui part
local Energy = 10 -- CURRENT ENERGY, this goes down whenever you press T, and regenerates some time.
local MaxEnergy = 10 -- MAX ENERGY
PhysicalBar.Stamina.SurfaceGui.Main.UIGradient.Offset = Vector2.new(-((Energy / MaxEnergy) * 0.45), 0)
I multiply it by 0.45 because of the UIGradient offset. If Energy / MaxEnergy is 1, then it will be 0.45, and 0.45 offset will make the blue bar invisible.
The video shows me using up stamina, my stamina decreases from 10 to 9, and so on. When it decreases, the blue bar below my character fills up, and that wasn’t really the way I wanted it to fill up - I wanted the blue, circular bar to be filled when my stamina is full, and decrease when I use stamina.
local Energy = 10
local MaxEnergy = 10
print(0.9 - (Energy/MaxEnergy) * 0.45)
Still produces the same result as 0.45 since Energy/MaxEnergy is 1, so if the stamina is max it will still be empty. It also produces weird results when stamina is a lower number (e.g. 0.9 - 5/MaxEnergy * 0.45 = 0.675)