Advertisement
AALTTz

ctrl to sprint by zen

Jun 17th, 2023
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. -- please give credit - zen
  2.  
  3. local player = game.Players.LocalPlayer
  4. local character = player.Character or player.CharacterAdded:Wait()
  5. local humanoid = character:WaitForChild("Humanoid")
  6. local isSprinting = false
  7. local normalWalkSpeed = humanoid.WalkSpeed
  8. local sprintWalkSpeed = 30
  9.  
  10. local function startSprinting()
  11. if isSprinting then
  12. return
  13. end
  14.  
  15. isSprinting = true
  16. humanoid.WalkSpeed = sprintWalkSpeed
  17. end
  18.  
  19. local function stopSprinting()
  20. if not isSprinting then
  21. return
  22. end
  23.  
  24. isSprinting = false
  25. humanoid.WalkSpeed = normalWalkSpeed
  26. end
  27.  
  28. game:GetService("UserInputService").InputBegan:Connect(function(input)
  29. if input.KeyCode == Enum.KeyCode.LeftControl then
  30. startSprinting()
  31. end
  32. end)
  33.  
  34. game:GetService("UserInputService").InputEnded:Connect(function(input)
  35. if input.KeyCode == Enum.KeyCode.LeftControl then
  36. stopSprinting()
  37. end
  38. end)
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement