Advertisement
XiByteGam123457890

Shift to sprint advanced

May 11th, 2024
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. Shift to sprint advanced
  2. -------------------------------------------------------------------------------------
  3. local player = game.Players.LocalPlayer
  4. local character = player.Character or player.CharacterAdded:Wait()
  5. local humanoid = character:WaitForChild("Humanoid")
  6.  
  7. local normalWalkSpeed = 16
  8. local sprintWalkSpeed = 32
  9.  
  10. -- Function to set the walkspeed
  11. local function setWalkSpeed(speed)
  12. humanoid.WalkSpeed = speed
  13. end
  14.  
  15. -- Detect when the Shift key is pressed
  16. game:GetService("UserInputService").InputBegan:Connect(function(input)
  17. if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift then
  18. setWalkSpeed(sprintWalkSpeed)
  19. end
  20. end)
  21.  
  22. -- Detect when the Shift key is released
  23. game:GetService("UserInputService").InputEnded:Connect(function(input)
  24. if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.RightShift then
  25. setWalkSpeed(normalWalkSpeed)
  26. end
  27. end)
  28. -------------------------------------------------------------------------------------
  29. -poke
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement