Advertisement
LockdateforGHS

Shift to Sprint (ROBLOX)

Jun 25th, 2023
1,900
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.87 KB | None | 0 0
  1. -- Place this script inside a LocalScript in StarterPlayerScripts
  2.  
  3. local player = game.Players.LocalPlayer
  4. local character = player.Character or player.CharacterAdded:Wait()
  5. local humanoid = character:WaitForChild("Humanoid")
  6. local userInputService = game:GetService("UserInputService")
  7.  
  8. local isSprinting = false
  9. local walkSpeed = humanoid.WalkSpeed
  10. local sprintSpeed = 2 * walkSpeed -- You can adjust the sprint speed multiplier here
  11.  
  12. local function onKeyPress(input)
  13.     if input.KeyCode == Enum.KeyCode.LeftShift then
  14.         isSprinting = true
  15.         humanoid.WalkSpeed = sprintSpeed
  16.     end
  17. end
  18.  
  19. local function onKeyRelease(input)
  20.     if input.KeyCode == Enum.KeyCode.LeftShift then
  21.         isSprinting = false
  22.         humanoid.WalkSpeed = walkSpeed
  23.     end
  24. end
  25.  
  26. userInputService.InputBegan:Connect(onKeyPress)
  27. userInputService.InputEnded:Connect(onKeyRelease)
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement