Stamina/Sprint function not working properly? Any Ideas?
Asked by
8 years ago Edited 8 years ago
Alright so I have this stamina/sprint (local) script and its not preforming like I expected...
Instead of it actually letting you run, it doesn't..
1. the while true do loops only runs once?
2. It wont let you run and stop running?
01 | local InputService = game:GetService( "UserInputService" ) |
02 | local Player = game:GetService( "Players" ).LocalPlayer |
03 | local Character = Player.Character or Player.CharacterAdded:wait() |
04 | local Humanoid = Character:WaitForChild( "Humanoid" ) |
05 | local IsSprinting = script.Parent.Variables.IsSprinting |
07 | if (IsSprinting.Value = = false ) then |
08 | if (script.Parent.Variables.Stamina.Value < 100 ) then |
10 | script.Parent.Variables.Stamina.Value = script.Parent.Variables.Stamina.Value + 1 |
11 | script.Parent.GUI.Stamina.Text = "Stamina: " ..script.Parent.Variables.Stamina.Value.. "%" |
17 | if (IsSprinting.Value = = true ) then |
18 | if (script.Parent.Variables.Stamina.Value < 0 ) then |
20 | script.Parent.Variables.Stamina.Value = script.Parent.Variables.Stamina.Value - 1 |
21 | script.Parent.GUI.Stamina.Text = "Stamina: " ..script.Parent.Variables.Stamina.Value.. "%" |
27 | InputService.InputBegan:connect( function (Input) |
28 | if Input.KeyCode = = Enum.KeyCode.LeftShift then |
29 | if script.Parent.Variables.Stamina.Value > 0 then |
30 | IsSprinting.Value = true |
31 | Humanoid.WalkSpeed = 25 |
36 | InputService.InputEnded:connect( function (Input) |
37 | if Input.KeyCode = = Enum.KeyCode.LeftShift then |
38 | IsSprinting.Value = false |
39 | Humanoid.WalkSpeed = 16 |