wait()
local maxStamina = script.Parent["StaminaRegen "].MaxStamina
local currentstamina = script.Parent["StaminaRegen "].CurrentStamina
local isRegen = false
local debounce = false
local running = script.Parent["StaminaRegen "].running
local Player = game.Players.LocalPlayer --local player
local Character = Player.Character --character
local Humanoid = Character:FindFirstChild("Humanoid") --finds the humanoid from the players character
while currentstamina.Value <= maxStamina.Value do
if not running.Value then
wait(0.5)
print("Antonio Stupid")
end
end
currentstamina.Changed:Connect(function()
print("2")
if not debounce then
debounce = true
print("3")
if not isRegen and currentstamina.Value < maxStamina.Value then
isRegen = true
print("4")
end
debounce = true
end
end)
local regenCo = coroutine.resume(coroutine.create(function()
while true do wait(.5) -- how fast stamina will be regen
if isRegen then
currentstamina.Value += 1 -- how much stamina will be regen
print("2")
if currentstamina.Value >= maxStamina.Value then
currentstamina.Value = maxStamina.Value
isRegen = false
print("3")
end
end
end
end))
Okay, I have a script that should regenerate stamina if the character walks or stands. And if heβs running, then donβt touch stamina. The problem is that this script does not work. What to do? There are no errors.
P.S. I have a working script that when dash spends stamina. But the regeneration does not work
If anything, hereβs where all the files are