Shift To Sprint Script

Press Shift to Sprint Script

You can use this shift to sprint script to make players run in your games with a really easy accessible key of “Shift”. In this case you can change how the script works, change the key they press to sprint or to change how much FOV changes when running. Or even if you don’t want the script to change the players.

How it works

This script works being in the StarterPlayerScripts area then can be used to make a player walk faster than the normal speed they go at. Eg. When a player presses “Shift” it will make them go fast like as if they are running, also it makes the FOV larger to show how much the speed feels like if you went that fast in real life.

Click here to get the script.

Mobile Support Version (Tablets, iPads and Mobile Phones etc)

SpeedScriptRunner now has mobile support to allow mobile devices such as tablets, ipads and mobile phones to be able to sprint using this script. The mobile version allows the user to toggle between sprinting and walking speeds by using a button. I have tested it number of times to ensure that it understands the difference between mobile devices and desktop/laptop devices. Currently, Xbox controllers are not compatible but hoping to add them soon.

Click here to get the mobile supported version.

Thanks for all the feedback by the way, Very appreciated!

91 Likes

Thanks for sharing! Does it also have an option which disables Shift Lock? Sorry if there is and I don’t see it, but I’m on mobile right now.

10 Likes

I never thought of shift Lock, I guess when people use shift lock it might not work. Thanks for the feedback by the way.
Maybe I could make it so it ignores the shift lock or checks if you have shift lock on.
Thanks I never thought about the shift lock.

2 Likes

Alternatively, a remapping of what key the shift lock should be done. Like the previous game I played, they remapped it to ctrl instead.

1 Like

Its easy to change, you can change it to any key you like, by doing

Enum.KeyCode.LeftControl

Some times I use “Q” because its near the “W” to move and it does not mess up with the shift lock thing; but then that would be the same if you changed it to anything but the “LeftShift” Key.

Thanks for the feedback!

1 Like

Fistly you need to make this script (in workspace)

Code 1

function onPlayerEntered(player)
repeat wait () until player.Character ~= nil
local s = script.SprintScript:clone()
s.Parent = player.Character
s.Disabled = false
player.CharacterAdded:connect(function (char)
local s = script.SprintScript:clone()
s.Parent = char
s.Disabled = false
end)
end

game.Players.PlayerAdded:connect(onPlayerEntered)

Then you need put into that code this code

Code 2

local mouse = game.Players.LocalPlayer:GetMouse()
local running = false

function getTool()
for _, kid in ipairs(script.Parent:GetChildren()) do
if kid.className == “Tool” then return kid end
end
return nil
end

mouse.KeyDown:connect(function (key) – Run function
key = string.lower(key)
if string.byte(key) == 48 then
running = true
local keyConnection = mouse.KeyUp:connect(function (key)
if string.byte(key) == 48 then
running = false
end
end)
for i = 1,5 do
game.Workspace.CurrentCamera.FieldOfView = (70+(i2))
wait()
end
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 40
repeat wait () until running == false
keyConnection:disconnect()
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
for i = 1,5 do
game.Workspace.CurrentCamera.FieldOfView = (80-(i
2))
wait()
end
end
end)

this is all what you need !

4 Likes

Thats great but it’s not really simple and easy to read from, but it can be perfectly put in a good layout like mine but does the same check. I am guessing the;

function getTool()
for _, kid in ipairs(script.Parent:GetChildren()) do
if kid.className == “Tool” then return kid end
end
return nil
end

is checking that is not in shift lock, or am I wrong?

1 Like

sadly but my script can’t work with shift lock but it perfectly work without shift lock .

1 Like

Yes using a different key can get around the shift lock problem, but most people might not use it - or a game developer could disable it or something.

Thanks for the feedback by the way!

2 Likes

Awesome resource,

any way to restrict this to a rank in a group and any rank above that>

1 Like

You could try adding an if statement checking if player has a certain role in the group like this,

if player:GetRoleInGroup([groupId]) == [rank name] then
   -- [the code to sprint]
   else
   -- [print something or do nothing]
end

To make it so that higher ranks can sprint you just repeat this with the higher ranks name.

3 Likes

You can disable ShiftLock by going to StarterPlayer, and disabling EnableMouseLockOption

2 Likes

Awesome, thank you so much!

I’m thinking of using it in my game so HR (high ranks) can sprint.

I also might do it where you can buy a gamepass, I’ll have to find a script for that one.

:heart:

1 Like

There’s resources online on how to script these kind of things. I suggest you to learn how to script gamepass features in your game.

3 Likes

Yes, I am learning how to script.

I know some resources like youtube and scripting helpers.

Cheers, :smile:

3 Likes

Awesome resource and cool discussion on scripting! Overall the script is real well organized and made. Great job on that!

Its cool how other people are also adding onto it to work with certain scenarios.

@msami7893 If you’re planning on adding the limitation for group ranks, heres a tip on security because the script operates only locally, and attackers do have the power to manipulate the behavior of local scripts.

You might want to have server involvement, especially if using with a gamepass. A model would look something like a server script checking players credentials when they join and duplicating the script into their playerScripts storage if they have access. Then its a good practice to have the server verify anything that player performs or communicates to the server as a double check.

Of course its a speed script and not entirely necessary, but I think you’ll find understanding client-server models useful especially learning scripting and scripting securely. Best of luck!

3 Likes

Hello,
Maybe for more security make it load from a server script and then make it local after the player loaded, or even keeping the script server all times.
All you need is to get the character from the player and you are ready to go. I might make it a server script in some time to show how it would work.

Thanks for all the feedback by the way!

1 Like

I’m thinking gamepass not rank, but I’m not really bothered if exploiters can speed as most exploit programs already have features to speed a character from what I understand.

I don’t know how to script all of that so I might have to hire someone or really try hard to learn. Thank you for the instructions though.

2 Likes

Sorry for the bump but I would like to have mobile support of this script for my mobile users, thanks and have a great day :slightly_smiling_face:

2 Likes

Hello, I see you want mobile support. Sadly, I created this ages ago and I do not believe I want to improve on it anymore. What I would do is create a button which handles while someone is holding it / clicked it it will make the player sprint. However, for now I will not be updating this code.

I hope you understand.

3 Likes