Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Put LocalScript in StarterPlayerScripts
- local Player = game:GetService("Players").LocalPlayer
- local Humanoid = nil
- local UserInputService = game:GetService("UserInputService")
- local isRunning = false
- local triggerKey = Enum.KeyCode.LeftShift
- local REGULAR_SPEED = 16
- local RUN_SPEED = 30
- local function connectToHumanoid(character)
- Humanoid = character:WaitForChild("Humanoid")
- UserInputService.InputBegan:Connect(function(input)
- if input and input.KeyCode == triggerKey then
- Humanoid.WalkSpeed = RUN_SPEED
- isRunning = true
- end
- end)
- UserInputService.InputEnded:Connect(function(input)
- if input and input.KeyCode == triggerKey then
- Humanoid.WalkSpeed = REGULAR_SPEED
- isRunning = false
- end
- end)
- end
- connectToHumanoid(Player.Character or Player.CharacterAdded:Wait())
- Player.CharacterAdded:Connect(function(character)
- if Humanoid then
- Humanoid:Destroy()
- end
- connectToHumanoid(character)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement