Here is how to make a shift to sprint option for your game.
To Start we need to make the script Make it as Class LocalScript and we will place this script In game.StarterPlayer.StarterPlayerScripts < It is up to you where to put it as long as it works.
First in the script lets define the UserInputService.
-- Variables --
local uis = game:GetService("UserInputService") -- This gives us the power to check what key they are clicking
local isPressing = false -- this will check if they are Holding the shift key or not
Next we will check when the person click a keys
-- Variables --
local uis = game:GetService("UserInputService") -- This gives us the power to check what key they are clicking
local isPressing = false -- this will check if they are Holding the shift key or not
-- Functions --
uis.InputBegan:Connect(function(Input)-- This will check when they start holding the Shift button
end) -- Ends checking InputBegan
Now we want to check if they are clicking the shift button (both Left and Right)
- Variables --
local uis = game:GetService("UserInputService") -- This gives us the power to check what key they are clicking
local isPressing = false -- this will check if they are Holding the shift key or not
-- Functions --
uis.InputBegan:Connect(function(Input)-- This will check when they start holding the Shift button
if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.RightShift then -- This will Check if they are clicking they shift key
isPressing = true -- They are pressing Shift Key
end -- ends the if statement
end) -- Ends checking InputBegan
Now we will finally apply the speed changes when they click shift.
-- Variables --
local uis = game:GetService("UserInputService") -- This gives us the power to check what key they are clicking
local isPressing = false -- this will check if they are Holding the shift key or not
-- Functions --
uis.InputBegan:Connect(function(Input)-- This will check when they start holding the Shift button
if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.RightShift then -- This will Check if they are clicking they shift key
isPressing = true -- They are pressing Shift Key
end -- ends the if statement
while true do -- Continues looping through to see if they are clicking right key
wait() -- This keeps the game from Crashing
if isPressing then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25 -- Increases there speed when they are holding shift
end-- ends the if
end -- ends loop
end)-- Ends checking InputBegan
Next we want to check if they have stopped clicking the shift key we do that with InputEnded.
From here everything is basically going to be opposite.
-- Variables --
local uis = game:GetService("UserInputService") -- This gives us the power to check what key they are clicking
local isPressing = false -- this will check if they are Holding the shift key or not
-- Functions --
uis.InputBegan:Connect(function(Input)-- This will check when they start holding the Shift button
if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.RightShift then -- This will Check if they are clicking they shift key
isPressing = true -- They are pressing Shift Key
end -- ends the if statement
while true do -- Continues looping through to see if they are clicking right key
wait() -- This keeps the game from Crashing
if isPressing then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25 -- Increases there speed when they are holding shift
end-- ends the if
end -- ends loop
end)-- Ends checking InputBegan
uis.InputEnded:Connect(function(Input) -- This will check when they stop holding the Shift button
end) -- Ends checking InputEnded
Now we want to check if the released the shift key and not another key.
-- Variables --
local uis = game:GetService("UserInputService") -- This gives us the power to check what key they are clicking
local isPressing = false -- this will check if they are Holding the shift key or not
-- Functions --
uis.InputBegan:Connect(function(Input)-- This will check when they start holding the Shift button
if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.RightShift then -- This will Check if they are clicking they shift key
isPressing = true -- They are pressing Shift Key
end -- ends the if statement
while true do -- Continues looping through to see if they are clicking right key
wait() -- This keeps the game from Crashing
if isPressing then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25 -- Increases there speed when they are holding shift
end-- ends the if
end -- ends loop
end)-- Ends checking InputBegan
uis.InputEnded:Connect(function(Input) -- This will check when they stop holding the Shift button
if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.RightShift then -- This will Check if they stop clicking they shift key
isPressing = false -- They are not pressing Shift Key
end-- ends the if statement
end) -- Ends checking InputEnded
Finally we need to make it so they loose that speed when they release shift. To do that we add a while loop.
-- Variables --
local uis = game:GetService("UserInputService") -- This gives us the power to check what key they are clicking
local isPressing = false -- this will check if they are Holding the shift key or not
-- Functions --
uis.InputBegan:Connect(function(Input)-- This will check when they start holding the Shift button
if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.RightShift then -- This will Check if they are clicking they shift key
isPressing = true -- They are pressing Shift Key
end -- ends the if statement
while true do -- Continues looping through to see if they are clicking right key
wait() -- This keeps the game from Crashing
if isPressing then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25 -- Increases there speed when they are holding shift. Can Be Changed to your desire.
end-- ends the if
end -- ends loop
end)-- Ends checking InputBegan
uis.InputEnded:Connect(function(Input) -- This will check when they stop holding the Shift button
if Input.KeyCode == Enum.KeyCode.LeftShift or Input.KeyCode == Enum.KeyCode.RightShift then -- This will Check if they stop clicking they shift key
isPressing = false -- They are not pressing Shift Key
end-- ends the if statement
while true do -- Continues looping through to see if they are done clicking the right key
wait()-- This keeps the game from Crashing
if not isPressing then -- Checks if they are done pressing shift button.
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 -- Decreases there speed when they are holding shift. Default Walk Speed.
end -- ends the if statement
end -- ends loop
end) -- Ends checking InputEnded
If you want it or It didn’t work for you go Here its uncopylocked: Shift to sprint Place .
Also Please Like these tutorials take a little bit to make but they are worth it in the end.
Thanks!
lolhi0404