How would I force the stamina bar to go up even if holding shift still?
Ok so, I have the script and everything works amazingly, but theres one big problem. When the stamina bar gets to 0 and you're still holding shift instead of it going back up and the FOV reverting back it stays down and you stay in the runnning fov but walking. I want the FOV to go back to normal and the players Stamina to go up even if they're holding shift. Here's the code
02 | local camera = game.Workspace.CurrentCamera |
03 | local TweeningService = game:GetService( "TweenService" ) |
04 | local UIS = game:GetService( "UserInputService" ) |
05 | local Bar = script.Parent:WaitForChild( 'Border' ):WaitForChild( "Bar" ) |
06 | local player = game.Players.LocalPlayer |
10 | local sprinting = false |
11 | repeat wait() until game.Players.LocalPlayer.Character |
12 | local character = player.Character |
13 | local runService = game:GetService( 'RunService' ) |
20 | local TweenInformation = TweenInfo.new( |
22 | Enum.EasingStyle.Quint, |
23 | Enum.EasingDirection.Out, |
29 | local tween = TweeningService:Create(camera, TweenInformation, FOVChanges) |
35 | local TweenInformation 2 = TweenInfo.new( |
37 | Enum.EasingStyle.Quint, |
38 | Enum.EasingDirection.Out, |
44 | local tween 2 = TweeningService:Create(camera, TweenInformation 2 , FOVChanges 2 ) |
47 | UIS.InputBegan:Connect( function (key, gameProcessed) |
48 | if key.KeyCode = = Enum.KeyCode.LeftShift and gameProcessed = = false and character.Humanoid:GetState() = = Enum.HumanoidStateType.RunningNoPhysics and character.Humanoid.MoveDirection.Magnitude > 0 then |
49 | character.Humanoid.WalkSpeed = run |
51 | while power > 0 and sprinting do |
53 | Bar.Size = UDim 2. new(power / 10 , 0 , 1 , 0 ) |
57 | character.Humanoid.WalkSpeed = walk |
64 | UIS.InputEnded:Connect( function (key, gameProcessed) |
65 | if key.KeyCode = = Enum.KeyCode.LeftShift and gameProcessed = = false then |
66 | character.Humanoid.WalkSpeed = walk |
68 | while power < 10 and not sprinting do |
70 | Bar.Size = UDim 2. new(power / 10 , 0 , 1 , 0 ) |
74 | character.Humanoid.WalkSpeed = walk |