Advertisement
FazeWolfyBoy

Sprint To Run

Apr 28th, 2022
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. local userInput = game:GetService("UserInputService")
  2.  
  3. local players = game:GetService("Players")
  4.  
  5.  
  6.  
  7. local sprintSpeed = 30
  8.  
  9. local walkSpeed = 16
  10.  
  11.  
  12.  
  13. local player = players.LocalPlayer
  14.  
  15.  
  16.  
  17. local function beginSprint(input, gameProcessed)
  18.  
  19. if not gameProcessed then
  20.  
  21. if input.UserInputType == Enum.UserInputType.Keyboard then
  22.  
  23. local keycode = input.KeyCode
  24.  
  25. if keycode == Enum.KeyCode.LeftShift then
  26.  
  27. player.Character.Humanoid.WalkSpeed = sprintSpeed
  28.  
  29. end
  30.  
  31. end
  32.  
  33. end
  34.  
  35. end
  36.  
  37.  
  38.  
  39. local function endSprint(input, gameProcessed)
  40.  
  41. if not gameProcessed then
  42.  
  43. if input.UserInputType == Enum.UserInputType.Keyboard then
  44.  
  45. local keycode = input.KeyCode
  46.  
  47. if keycode == Enum.KeyCode.LeftShift then
  48.  
  49. player.Character.Humanoid.WalkSpeed = walkSpeed
  50.  
  51. end
  52.  
  53. end
  54.  
  55. end
  56.  
  57. end
  58.  
  59.  
  60.  
  61. userInput.InputBegan:Connect(beginSprint)
  62.  
  63. userInput.InputEnded:Connect(endSprint)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement