There is an "Attempt to index nil with Value error. Can anyone please fix it?
local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Humanoid = Character:WaitForChild("Humanoid") local IsSprinting = Player:WaitForChild("IsSprinting") local Stamina = Player:WaitForChild("Stamina") local UserInputService = game:GetService("UserInputService") UserInputService.InputBegan:Connect(function(Input,GameProcessed) if GameProcessed or Stamina == 0 then return end if Input.KeyCode == Enum.KeyCode.LeftShift then Humanoid.WalkSpeed = Character.Humanoid.WalkSpeed + 8 IsSprinting.Value = true end end) UserInputService.InputEnded:Connect(function(Input) if Input.KeyCode == Enum.KeyCode.LeftShift then Humanoid.WalkSpeed = Character.Humanoid.WalkSpeed - 8 IsSprinting.Value = false end end) while wait() do if Stamina == 0 and IsSprinting.Value == true then IsSprinting = false Humanoid.WalkSpeed = 16 end if IsSprinting.Value == true and Humanoid.MoveDirection.Magnitude > 0 then Stamina.Value = Stamina.Value - 1 wait(1) else Stamina.Value = Stamina.Value + 1 wait(1) end Stamina = math.clamp(Stamina.Value,0,100) end