I have attempted to make a stamina system but the problem is that whenever I start the game and look at the output it goes negative and in a second it'd be -1000 and whenever you start running it'd go up there is no part of the script that would do this
so that means the amount of time of running will take longer to deplete stamina if you don't run edit: if your wondering why I have renderstepped, there's code that is not part of the issue
local timeyouahavebeenrunning = 0
RunService.RenderStepped:Connect(function()
local stamina = 6
if timeyouahavebeenrunning == stamina then
camera.FieldOfView = 68
humanoid.WalkSpeed = 14
wait(6)
timeyouahavebeenrunning = timeyouahavebeenrunning - timeyouahavebeenrunning
elseif Userinputservice:IsKeyDown(Enum.KeyCode.LeftShift) or Userinputservice:IsKeyDown(Enum.KeyCode.RightShift) then
camera.FieldOfView = 80
humanoid.WalkSpeed = 23
repeat
timeyouahavebeenrunning = timeyouahavebeenrunning + 1
wait(1)
until timeyouahavebeenrunning == 6
else
camera.FieldOfView = 70
humanoid.WalkSpeed = 16
repeat
timeyouahavebeenrunning = timeyouahavebeenrunning - 1
wait(1)
until Userinputservice:IsKeyDown(Enum.KeyCode.LeftShift)or Userinputservice:IsKeyDown(Enum.KeyCode.RightShift) or timeyouahavebeenrunning == 0
end
end)

2 comments
Either I did it wrong but didn't work, can you show me?
Plus, the waiting is meant for how long you can run, I want to run for 6 seconds