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?
local InputService = game:GetService("UserInputService") local Player = game:GetService("Players").LocalPlayer local Character = Player.Character or Player.CharacterAdded:wait() local Humanoid = Character:WaitForChild("Humanoid") local IsSprinting = script.Parent.Variables.IsSprinting while true do if(IsSprinting.Value == false) then if(script.Parent.Variables.Stamina.Value < 100) then wait(.25) script.Parent.Variables.Stamina.Value = script.Parent.Variables.Stamina.Value + 1 script.Parent.GUI.Stamina.Text = "Stamina: "..script.Parent.Variables.Stamina.Value.."%" return end end end while true do if(IsSprinting.Value == true) then if(script.Parent.Variables.Stamina.Value < 0) then wait(.05) script.Parent.Variables.Stamina.Value = script.Parent.Variables.Stamina.Value - 1 script.Parent.GUI.Stamina.Text = "Stamina: "..script.Parent.Variables.Stamina.Value.."%" return end end end InputService.InputBegan:connect(function(Input) if Input.KeyCode == Enum.KeyCode.LeftShift then if script.Parent.Variables.Stamina.Value > 0 then IsSprinting.Value = true Humanoid.WalkSpeed = 25 end end end) InputService.InputEnded:connect(function(Input) if Input.KeyCode == Enum.KeyCode.LeftShift then IsSprinting.Value = false Humanoid.WalkSpeed = 16 end end)
You put a return in the while loops, ending them once reached. Just take them out and it should run fine