Im working on making a stamina script where it always checks (in a span of 3 seconds) if the stamina has changed or not. If it hasnt, then it will gradually increase until it detects it is decreased again.
Here is my script:
while wait(.167) do if c:FindFirstChild("Stamina") then local stamina = c:FindFirstChild("Stamina").Value spawn(function() delay(3,function () if c:FindFirstChild("Stamina").Value == stamina and stamre == false then stamre = true else stamre = false end end) end) if stamre == true then c.Stamina.Value = c.Stamina.Value + 1 end end end
And it isnt working too well. Can someone help fix it up for me? Thanks
local staminaValue = --Put value here function Increase() --Code to increase stamina over 3 seconds here end lastStam = 0 while wait(3) do if staminaValue.Value >= lastStam then Increase() end lastStam = staminaValue end
Short and simple. It checks if the stamina is going down every 3 seconds and if it's not then it will increase. If it is then it won't do anything. Comment if you need further assistance.