Advertisement
EconomicSerg

Shift To Sprint

Jan 11th, 2021
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. -- Add a LocalScript into StarterGui, and add a Configurations folder with 2 number values: runSpeed and normalSpeed
  2. -- Btw I dont indent
  3.  
  4. -- Services
  5. local inputService = game:GetService("UserInputService")
  6. local playerService = game:GetService("Players")
  7.  
  8. -- Objects
  9. local plr = playerService.LocalPlayer
  10. local char = plr.Character or plr.CharacterAdded:Wait()
  11. local settingsDir = script.Settings
  12.  
  13. function getSetting (name)
  14. return settingsDir and settingsDir:FindFirstChild(name) and settingsDir[name].Value
  15. end
  16.  
  17. local normalSpeed = getSetting("WalkSpeed") or 16
  18. local runSpeed = getSetting("RunSpeed") or 26
  19. local running = false
  20.  
  21. inputService.InputBegan:Connect(function(Key)
  22. if Key.KeyCode == Enum.KeyCode.LeftShift or Key.KeyCode == Enum.KeyCode.RightShift then
  23. running = true
  24. if char.Humanoid then
  25. char.Humanoid.WalkSpeed = runSpeed
  26. end
  27. end
  28. end)
  29.  
  30. inputService.InputEnded:Connect(function(Key)
  31. if Key.KeyCode == Enum.KeyCode.LeftShift or Key.KeyCode == Enum.KeyCode.RightShift then
  32. running = false
  33. if char.Humanoid then
  34. char.Humanoid.WalkSpeed = normalSpeed
  35. end
  36. end
  37. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement