Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local plr = game.Players.LocalPlayer --Player
- local sprintSpeed = 30 --Configuration
- local normalSpeed =16
- local function sprintCharacter(on) --Function makes it easier to control with just a boolean
- if plr.Character then
- if on then --If it's on, set the walkspeed to sprinting
- plr.Character.Humanoid.WalkSpeed = sprintSpeed
- else --If it's not, set the walkspeed to normal
- plr.Character.Humanoid.WalkSpeed = normalSpeed
- end
- end
- end
- game:GetService("UserInputService").InputBegan:connect(function(input, processed)
- if input.UserInputType == Enum.UserInputType.Gamepad1 then
- if input.KeyCode == Enum.KeyCode.ButtonL2 then --When the gamepad left trigger is pressed
- sprintCharacter(true) --Sprint
- end
- end
- end)
- game:GetService("UserInputService").InputEnded:connect(function(input, processed)
- if input.UserInputType == Enum.UserInputType.Gamepad1 then
- if input.KeyCode == Enum.KeyCode.ButtonL2 then --When the gamepad's left trigger is released
- sprintCharacter(false) --Stop sprinting
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement