Advertisement
Drvays

Shift To Sprint

May 30th, 2021
7,571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. local userInput = game:GetService("UserInputService")
  2. local players = game:GetService("Players")
  3.  
  4. local sprintSpeed = 30
  5. local walkSpeed = 16
  6.  
  7. local player = players.LocalPlayer
  8.  
  9. local function beginSprint(input, gameProcessed)
  10. if not gameProcessed then
  11. if input.UserInputType == Enum.UserInputType.Keyboard then
  12. local keycode = input.KeyCode
  13. if keycode == Enum.KeyCode.LeftShift then
  14. player.Character.Humanoid.WalkSpeed = sprintSpeed
  15. end
  16. end
  17. end
  18. end
  19.  
  20. local function endSprint(input, gameProcessed)
  21. if not gameProcessed then
  22. if input.UserInputType == Enum.UserInputType.Keyboard then
  23. local keycode = input.KeyCode
  24. if keycode == Enum.KeyCode.LeftShift then
  25. player.Character.Humanoid.WalkSpeed = walkSpeed
  26. end
  27. end
  28. end
  29. end
  30.  
  31. userInput.InputBegan:Connect(beginSprint)
  32. userInput.InputEnded:Connect(endSprint)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement