Whenever stamina reaches 0 the camera starts to bug out. Please help!
Here’s my code:
function StartRun()
sprinting = true
Tween2:Pause()
Tween1:Play()
Humanoid.WalkSpeed = Run
Power -= .03
end
function StartWalk()
if Power < 10 then
sprinting = false
Tween1:Pause()
Tween2:Play()
Humanoid.WalkSpeed = Walk
Power += .01
end
end
function InputBegan(Input: Enum.KeyCode, gpe: boolean)
if Input.KeyCode ~= Key or gpe or Sprinting then return end
Sprinting = true
end
function InputEnded(Input: Enum.KeyCode, gpe: boolean)
if Input.KeyCode ~= Key or gpe then return end
Sprinting = false
end
UIS.InputBegan:Connect(InputBegan)
UIS.InputEnded:Connect(InputEnded)
while true do
if Sprinting then
if Humanoid.MoveDirection.Magnitude > 0 and Power > 0 then
StartRun()
else
StartWalk()
end
elseif not Sprinting and Power < 10 then
StartWalk()
end
UpdateBarSize()
task.wait()
end