(this was used for my roblox game don't worry about it) -Player Variables local Player = game.Players.LocalPlayer local Character = Player.Character or Player.CharacterAdded:Wait() local Humanoid = Character:WaitForChild("Humanoid") local Camera = workspace.CurrentCamera --Services local UserInputService = game:GetService("UserInputService") local TweenService = game:GetService("TweenService") local ReplicatedStorage = game:GetService("ReplicatedStorage") --Settings local DefaultSpeed = 12 --Default Walk Speed local RunSpeed = 25 --Default Run Speed local DefaultFOV = 70 --Default FOV (Camera Zoom) local RunFOV = 90 --Running FOV (Camera Zoom) --Run Keybind local PCKeybind1 = Enum.KeyCode.LeftShift local PCKeybind2 = Enum.KeyCode.RightShift local XboxKeybind1 = Enum.KeyCode.ButtonL2 --Zoom Anim Settings local zoomSettings = TweenInfo.new(.5, Enum.EasingStyle.Quad, Enum.EasingDirection.Out) --Time, EnumStyle, EnumDirection --Anims local zoomIn = TweenService:Create(Camera, zoomSettings, {FieldOfView = DefaultFOV}) local zoomOut = TweenService:Create(Camera, zoomSettings, {FieldOfView = RunFOV}) local Animator = Humanoid:WaitForChild("Animator") local SprintAnim = Animator:LoadAnimation(script:WaitForChild("Sprint")) --Pressed run button UserInputService.InputBegan:Connect(function(Input, Processed) if Processed then return end if Input.KeyCode == PCKeybind1 or Input.KeyCode == PCKeybind2 or Input.KeyCode == XboxKeybind1 then zoomOut:Play() SprintAnim:Play() Humanoid.WalkSpeed = RunSpeed end end) --Let go of run button UserInputService.InputEnded:Connect(function(Input, Processed) if Processed then return end if Input.KeyCode == PCKeybind1 or Input.KeyCode == PCKeybind2 or Input.KeyCode == XboxKeybind1 then SprintAnim:Stop() zoomIn:Play() Humanoid.WalkSpeed = DefaultSpeed end end) 77695527821353 123941717714418 18043579
Read comments