Whenever my power is 0 and holding shift the camera bugs out, I also want to make it so when power is 0 you have to wait 2 seconds. How would I do this?
Heres my code:
function UpdateBarSize()
Bar.Size = UDim2.fromScale(Power * .1, 1)
end
function StartRun()
Tween1:Play()
Humanoid.WalkSpeed = Run
Power -= .03
end
function StartWalk()
Tween2:Play()
Humanoid.WalkSpeed = Walk
Power += .01
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