Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Humanoid = script.Parent:FindFirstChild("Humanoid")
- local UserInputService = game:GetService("UserInputService")
- local Key = Enum.KeyCode.LeftShift
- local Camera = workspace.CurrentCamera
- local DefaultFOV = Camera.FieldOfView
- local SprintingFOV = DefaultFOV + 3
- local DefaultSpeed = game.StarterPlayer.CharacterWalkSpeed
- local SprintSpeed = DefaultSpeed * 2
- local TweenWaitTime = 0.15
- local Toggle = false
- local Sprinting = false
- local TweenService = game:GetService("TweenService")
- local MyTweenInfo = TweenInfo.new(TweenWaitTime, Enum.EasingStyle.Sine, Enum.EasingDirection.Out)
- local SprintingFOV_Properties = {FieldOfView = SprintingFOV}
- local DefaultFOV_Properties = {FieldOfView = DefaultFOV}
- local SpintingFOV_Animation = TweenService:Create(Camera, MyTweenInfo, SprintingFOV_Properties)
- local DefaultFOV_Animation = TweenService:Create(Camera, MyTweenInfo, DefaultFOV_Properties)
- UserInputService.InputBegan:Connect(function(Input)
- if Input.KeyCode == Key then
- if Toggle == false then
- Sprinting = true
- while Sprinting == true do
- SpintingFOV_Animation:Play()
- Humanoid.WalkSpeed = SprintSpeed
- wait()
- end
- else
- Sprinting = not Sprinting
- if Sprinting == true then
- SpintingFOV_Animation:Play()
- Humanoid.WalkSpeed = SprintSpeed
- elseif Sprinting == false then
- DefaultFOV_Animation:Play()
- Humanoid.WalkSpeed = DefaultSpeed
- end
- end
- end
- end)
- UserInputService.InputEnded:Connect(function(Input)
- if Input.KeyCode == Key then
- if Toggle == false then
- Sprinting = false
- while Sprinting == false do
- DefaultFOV_Animation:Play()
- Humanoid.WalkSpeed = DefaultSpeed
- wait()
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement