I want my user's in my game to be able to run/walk with the shift key. How do I do this?
✓ ANSWER ACCEPTED
How do I script a run/walk with the shift key?
1 answer
✓ Accepted answer
I would like to say, before I do this, that this is not a request site. I will help you out because You may not have read or understood that. In return though, I would like you to read and analyze the script, so you never have to ask this again. Thank You
Here is the script.
InputService = game:GetService("UserInputService") -- Sets a var to UserInputService
local plr = game.Players.LocalPlayer -- Sets Player
plr.CharacterAdded:Wait() -- Waits Until Player's Character has loaded in
plr.Character:WaitForChild("Humanoid") -- Waits Until Character's Child Humanoid Loads
local char = plr.Character -- sets a Variable to the player's character.
local hum = char.Humanoid -- Sets a Variable to Humanoid
InputService.InputBegan:Connect(function() -- Function for Input being given
local actionKey = Enum.KeyCode.LeftShift -- sets variable actionKey to LeftShift
local keysPressed = InputService:GetKeysPressed() -- sets Variable to a table of keys pressed
for _, key in ipairs(keysPressed) do -- set a loop to check for all keys pressed
if (key.KeyCode == actionKey) then -- checks If the key pressed is LeftShift
hum.WalkSpeed = 20 -- You can change these how you want
wait()
InputService.InputEnded:Connect(function() -- Function for InputEnded
hum.WalkSpeed = 16 -- Sixteen is the default walkspeed
end)
end
end
end)
Additional Notes-
-You must use a Local Script and put It in StarterPlayerScripts.
-Try to mess with It and make something cool out of it
-Please don't request Code on this site, and Instead request help with your code.
-Have Fun
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Thank you so much! But I'm not asking for someone to do it for me...I just wanted to know the script for it so I can do it.
you're welcome