Problem with stamina system

( I made the same post so people can see it )
i have a problem with my stamina system, the system is used everytime the player mines a rock, the stamina decreases and waits a few seconds before it regens again. I have a problem where everytime i mine a rock, the stamina bar just stops there, doesn’t do anything and doesn’t regen
robloxapp-20231106-2038214.wmv (614.8 KB)
Here is the script :

local rs = game:GetService("ReplicatedStorage")
local canmine = rs.Tool.Pickaxe.CanMine or rs.Tool.UpgradedPickaxe.CanMine
local mining = rs.Mining

local UIS = game:GetService("UserInputService")

local currentStamina = 250
local maxStamina = 250
local isRunning = false

currentStamina = math.clamp(currentStamina, 0, maxStamina)

local function updateStamina()
	if currentStamina > 0 then
		currentStamina = currentStamina - 25
		script.Parent:TweenSize(UDim2.new(0, 21, currentStamina / maxStamina, 0), "Out", "Linear", 0)
	end

	while currentStamina < 250 do
		currentStamina = currentStamina + 0.5
		script.Parent:TweenSize(UDim2.new(0, 21, currentStamina / maxStamina, 0), "Out", "Linear", 0)
	end
end

mining.OnServerEvent:Connect(function()
	updateStamina()
end)

You could check value that return :TweenSize() function,
TweenSize return true when Animation is success at playing and false for opposite

i don’t know what you mean by that and how would i do that?

local success = script.Parent:TweenSize(UDim2.new(0, 21, currentStamina / maxStamina, 0), "Out", "Linear", 0)
print(success and "Animation Played" or "Animation not Played")

I guess value has changed but it didnt appear at gui