I have attempted to make a stamina system and for some reason it's random?
Asked by
3 years ago Edited 3 years ago
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
01 | local timeyouahavebeenrunning = 0 |
02 | RunService.RenderStepped:Connect( function () |
06 | if timeyouahavebeenrunning = = stamina then |
07 | camera.FieldOfView = 68 |
08 | humanoid.WalkSpeed = 14 |
10 | timeyouahavebeenrunning = timeyouahavebeenrunning - timeyouahavebeenrunning |
11 | elseif Userinputservice:IsKeyDown(Enum.KeyCode.LeftShift) or Userinputservice:IsKeyDown(Enum.KeyCode.RightShift) then |
13 | camera.FieldOfView = 80 |
14 | humanoid.WalkSpeed = 23 |
18 | timeyouahavebeenrunning = timeyouahavebeenrunning + 1 |
21 | until timeyouahavebeenrunning = = 6 |
23 | camera.FieldOfView = 70 |
25 | humanoid.WalkSpeed = 16 |
28 | timeyouahavebeenrunning = timeyouahavebeenrunning - 1 |
31 | until Userinputservice:IsKeyDown(Enum.KeyCode.LeftShift) or Userinputservice:IsKeyDown(Enum.KeyCode.RightShift) or timeyouahavebeenrunning = = 0 |