Skip to content

Roblox speed script: All you need to know

  • by
  • 3 min read

Roblox is a pretty popular game among adults and children alike as not only can you play around in the hundreds of modes the game has, but you can also create your own and share them with the community. 

In this article, we’re looking at everything you need to know about Roblox speed scripts. 

Also read: Why does it say Roblox was unable to update? 12 Fixes


Speed scripts in Roblox

Speed scripts are used to control how fast the in-game character, also called a humanoid, can walk in terms of studs per second. The default speed is 16 but this number can be increased or decreased to control how fast the player moves in the game. Several game modes require the player to move faster than usual and writing a speed script is the best way for you as a developer to control that aspect. 

Roblox vehicle simulator

However, before you start writing speed scripts in Roblox, there are some considerations you need to keep in mind.

  • Movement speed is reduced to 87.5% when swimming and 70% when climbing. These numbers are relative to the walking speed or 16 studs per second.
  • When controlled on a mobile device or gamepad, the humanoid can walk slower than the default walking speed if the controlling joystick is closer to the centre.
  • At any given time, the humanoid’s walking speed can be obtained by reading the Humanoid.Running event.

Speed script to move faster in Roblox

Here’s a sample script you can use to move faster in the game. 

local Players = game.Players

local RunService = game:GetService(“RunService”)

local SpeedPerStud = 0.1 --Set the speed here

local StudsTraveled = 0

local LastPosition = nil

function playerAdded(player) --Fires when a player joins the server

local Speed = Instance.new(“NumberValue”) --Saves the player speed in case they die

Speed.Name = “SpeedValue”

Speed.Value = 16

Speed.Parent = player

local RootPartHeartbeat = nil

player.CharacterAdded:Connect(function(character)

LastPosition = character.HumanoidRootPart.Position

RootPartHeartbeat = RunService.Heartbeat:Connect(function()

if character:FindFirstChild(“HumanoidRootPart”) then –If the player jumps into the void or their character doesn’t exist for some reason, this will stop this block of code from running

local DistanceFromLastPosition = (character.HumanoidRootPart.Position-LastPosition).magnitude

Speed.Value = Speed.Value+(DistanceFromLastPosition*SpeedPerStud)

character.Humanoid.WalkSpeed = Speed.Value

LastPosition = character.HumanoidRootPart.Position

end

end)

end)

player.CharacterRemoving:Connect(function()

RootPartHeartbeat:Disconnect()

end)

end

Players.PlayerAdded:Connect(playerAdded)

The aforementioned script uses a multiplier variable called SpeedPerStud to slowly increment speed as the player progresses along the game.


Increasing speed on button press

You can further control the speed increase by binding the action to a button. Here’s how.

local player = game.Players.LocalPlayer

repeat wait() until player.Character

local char = player.Character

local hum = char:WaitForChild(“Humanoid”)

local inputService = game:GetService(‘UserInputService’)

local keys = {

[‘Enum.KeyCode.LeftShift’] = true; [‘Enum.KeyCode.RightShift’] = true;
}

inputService.InputBegan:connect(function(inputType)

if inputType.UserInputType == Enum.UserInputType.Keyboard then

— Make sure you’re checking for KeyBoard input only.

   local makeKeyCodeAString = tostring(inputType.KeyCode)

 if keys[makeKeyCodeAString] then

local speed = hum.WalkSpeed <= 16 and 30 or 16

— Ternary operator

— speed is equal to this

–[[

if hum.WalkSpeed <= 16 then

speed = 30

 else

speed = 16

    end

–]]

hum.WalkSpeed = speed

    end

   end

end)

The aforementioned script uses both the left and right shift keys to increase or decrease the character’s walking speed respectively.

Also read: How to fix Roblox error code 403?

Yadullah Abidi

Yadullah Abidi

Yadullah is a Computer Science graduate who writes/edits/shoots/codes all things cybersecurity, gaming, and tech hardware. When he's not, he streams himself racing virtual cars. He's been writing and reporting on tech and cybersecurity with websites like Candid.Technology and MakeUseOf since 2018. You can contact him here: yadullahabidi@pm.me.

>