Trying to get a stamina gui I am working on to auto regen?

So stm is the bar im tweening, stmvalue is a number value for stamina stmvalue2 is the maxstamina also a number value, I have tried multiple ways of doing this ive had the number value go up but the bar not go up with it I do not know if its a tweening error were its being told to tween so much or not but this is the final product I came up with this and it dose not work at all I need the bar to always update based on the number for stamina. after so many problems and no errors i gave up so I hope someone can help heres the code.

local stm = script.Parent
local stmvalue = script.Parent.Stamina
local stmvalue2 = script.Parent.MaxStamina.Value
local rs = game:GetService(“RunService”)
stm:TweenSize( * .236,0,0.02,1),“In”,“Linear”,1)

– regen
if stmvalue.Value > 100 then
stmvalue.Value = stmvalue.Value + 20
elseif stmvalue.Value > 100 then
stmvalue.Value = 100
elseif stmvalue.Value == 100 then



– auto update for regen

stm:TweenSize( * .236,0,0.02,1),“In”,“Linear”,1)

Divide the stamina value by the maximum stamina value and put that in the X Size argument of the UDim2 value (this could be it).

You also spelled RenderStepped wrong on line 11.

When setting the size or position of a GUI object, use either the Size property or Offset property. You shouldn’t use both at the same time.

And for the sake of organisation and easier to see the text, please keep your code formatted by using 3 backquotes (`) at the start and end of your code block.

1 Like

My bad, and i may not have explained the situation very well up top so If i change the number value my just typeing it in it works fine, although if I link it to a weapon that is being worked on and it is clicked multiple times for some reason the number wants to go back up but the actual stamina bar dose not.

I honestly don’t understand your question.
At which condition will the stamina regenerate and vice versa?