Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. local plr = game.Players.LocalPlayer --Player
  2. local sprintSpeed = 30 --Configuration
  3. local normalSpeed =16
  4. local function sprintCharacter(on) --Function makes it easier to control with just a boolean
  5. if plr.Character then
  6. if on then --If it's on, set the walkspeed to sprinting
  7. plr.Character.Humanoid.WalkSpeed = sprintSpeed
  8. else --If it's not, set the walkspeed to normal
  9. plr.Character.Humanoid.WalkSpeed = normalSpeed
  10. end
  11. end
  12. end
  13.  
  14. game:GetService("UserInputService").InputBegan:connect(function(input, processed)
  15. if input.UserInputType == Enum.UserInputType.Gamepad1 then
  16. if input.KeyCode == Enum.KeyCode.ButtonL2 then --When the gamepad left trigger is pressed
  17. sprintCharacter(true) --Sprint
  18. end
  19. end
  20. end)
  21. game:GetService("UserInputService").InputEnded:connect(function(input, processed)
  22. if input.UserInputType == Enum.UserInputType.Gamepad1 then
  23. if input.KeyCode == Enum.KeyCode.ButtonL2 then --When the gamepad's left trigger is released
  24. sprintCharacter(false) --Stop sprinting
  25. end
  26. end
  27. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement