( 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)