Build movement mechanics beyond default Roblox character movement — tune speed and jump height, add a sprint, a dash, and a double jump, and keep the final say on the server.
The default character walks at 16 studs per second and jumps the same height no matter what game it is in. That is fine for a baseplate — and wrong the moment your game has a speed boost, a dodge roll, or a double jump. Custom movement is about owning those numbers: one place that decides how the body moves, input that asks for a change, and a server that has the final say.
Every number that decides how a character moves lives on its Humanoid. WalkSpeed is exactly what it sounds like: studs per second. The other two control the jump — JumpPower when UseJumpPower is true (the classic 50), or JumpHeight in studs when it is false (the default 7.2).
local humanoid = character:WaitForChild("Humanoid")
humanoid.WalkSpeed = 24 -- default is 16 studs per second
humanoid.JumpPower = 60 -- default is 50
Those two lines are the whole lesson in miniature. Inside a character-spawn handler — the one from the characters lesson — they run on every respawn, so the always comes back with your tuning.
The defaults every spawn resets to are set on StarterPlayer — CharacterWalkSpeed and CharacterJumpPower. Set them once in the panel when the whole game should feel a certain way, and keep the code for changes that happen during play.
The Humanoid property that decides how many studs per second a character walks is
Sprinting is the simplest custom movement: hold Shift to run, release to walk. The code listens for the press, the release, and flips one number. Movement code for your own character belongs in a LocalScript under StarterPlayerScripts — the character is simulated on the 's own machine, so a change there is instant instead of waiting for a server round-trip.
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local player = Players.LocalPlayer
local WALK_SPEED = 16
local SPRINT_SPEED = 28
local function setSprinting(sprinting)
local character = player.Character
if not character then return end
local humanoid = character:FindFirstChildOfClass("Humanoid")
if not humanoid then return end
humanoid.WalkSpeed = sprinting and SPRINT_SPEED or WALK_SPEED
end
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if gameProcessedEvent then return end
if input.KeyCode == Enum.KeyCode.LeftShift then
setSprinting(true)
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.LeftShift then
setSprinting(false)
end
end)
Three details carry the whole thing. The gameProcessedEvent guard stops the sprint from firing while the is typing a capital letter in chat. The InputEnded handler is what stops it when they let go — without it the sprint never ends. And sprinting and SPRINT_SPEED or WALK_SPEED is Luau's pick-one idiom: the first value unless it is false, otherwise the second.
If your game has controllers, bind this as a ContextActionService action instead — one action, a keyboard key and a gamepad button, the same trick from the controller support lesson.
Write the one line that sets WalkSpeed to SPRINT_SPEED while sprinting and WALK_SPEED otherwise.
local WALK_SPEED = 16
local SPRINT_SPEED = 28
local function setSprinting(humanoid, sprinting)
-- sprint at 28, walk at 16
endWalking is a speed you hold; a dash is a burst of motion that should trail off on its own. So don't dash by cranking WalkSpeed — you would have to time it back down, and the keeps full steering at triple speed the whole way.
Set the character's velocity instead. AssemblyLinearVelocity is in studs per second, so one line gives you one deliberate shove:
local DASH_SPEED = 90
local function dash(character)
local humanoid = character:WaitForChild("Humanoid")
if humanoid.FloorMaterial == Enum.Material.Air then return end
local root = character.HumanoidRootPart
root.AssemblyLinearVelocity = root.CFrame.LookVector * DASH_SPEED
end
LookVector points where the character is facing, so this dashes forward whichever way they look. Physics takes over on the next frame: friction and gravity peel the speed down and the character lands back at walking pace. The FloorMaterial check keeps it honest — a dash is something you do with your feet on the ground, not a mid-air second engine.
root:ApplyImpulse(root.CFrame.LookVector * 5000) is the other way to do this. An impulse is a shove scaled by mass — heavier characters get the same feel — while setting velocity gives you the exact same starting speed for everyone. For a snappy dash, setting the velocity is easier to tune.
Why set AssemblyLinearVelocity for a dash instead of raising WalkSpeed?
The engine already handles the ground jump. The trick is that JumpRequest fires on every jump press, including the ones in mid-air where the default jump does nothing. So you count air presses, spend one on a second jump, and refill the count on landing.
local MAX_AIR_JUMPS = 1
local airJumpsUsed = 0
local humanoid = character:WaitForChild("Humanoid")
UserInputService.JumpRequest:Connect(function()
-- the ground jump belongs to the engine; only air presses spend one
if humanoid.FloorMaterial ~= Enum.Material.Air then return end
if airJumpsUsed >= MAX_AIR_JUMPS then return end
airJumpsUsed += 1
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
end)
humanoid.StateChanged:Connect(function(_, newState)
if newState == Enum.HumanoidStateType.Landed then
airJumpsUsed = 0 -- feet on the ground: the air jump is refilled
end
end)
ChangeState(Enum.HumanoidStateType.Jumping) is the programmatic jump — the same one the Space bar triggers. The StateChanged handler is the important half: Landed is the moment the feet touch down, and that is the only state that refills the air jump. Reset on the wrong state and the character can climb forever.
The air jump refills when the character touches down. Complete the check: if newState == Enum.HumanoidStateType. then airJumpsUsed = 0 end
Want a triple jump? Change MAX_AIR_JUMPS to 2. The pattern does not change — the count is the feature. Same story for a stamina bar that limits dashes: one more number, one more check.
Everything so far runs on the 's machine, and the moment another is watching, that is a problem: a LocalScript is also a the can run. The handler below is the one people write first — it takes a speed off the wire and trusts it. An exploiter fires the with speed = 500 and crosses the map in a second.
local SPRINT_SPEED = 28
sprintEvent.OnServerEvent:Connect(function(player, speed)
local character = player.Character
if not character then return end
character.Humanoid.WalkSpeed = speed
end)
The server should never read a speed off the wire. Rewrite the buggy line so it ignores the number the client sent and applies its own SPRINT_SPEED constant instead.
After the fix, the contract is one sentence: remotes carry intent, the server owns values. That is the same rule behind the dash cooldown below and the jump count above — a client can ask, but the numbers and the clock stay on the server.
Movement cannot be fully prevented client-side — the character is simulated on the 's machine, so a determined exploiter can always claim to move too fast. What the server can do is detect and correct it: re-check WalkSpeed on a timer, clamp it back to the allowed value, rate-limit the dash and sprint remotes, and keep the cooldowns server-side so a spammed remote does nothing.
A dash without a cooldown is a teleport. The rule is one subtraction: enough time since the last dash, or no dash. Write it once as a and the client can use it for instant feedback while the server uses the same logic as the real gate.
Write canDash so it returns true only when the cooldown has fully elapsed. The starter code prints the two answers — false, then true.
Every mechanic in this lesson now has the same shape: one named constant, one check, one place that decides. Sprint is a speed choice, dash is a velocity plus a cooldown, a double jump is a count that refills on Landed. When you add a wall run or a slide next, it is one more branch in the same controller — not a new system.
InputBegan with no InputEnded leaves the sprinting forever. Both halves or neither.Landed means feet down. Reset anywhere else and the air jump refills mid-flight.speed accepts 500. Send the intent, apply the constant.Your movement checklist, before you ship:
Landed; cooldowns count from the last use.An exploiter sets their own WalkSpeed to 500. Which server-side habit actually catches that?
None of this replaces the character's default movement — it tunes it. The Humanoid still walks, jumps, and falls exactly as before; you have added named speeds, a burst, a counted jump, and the two rules that keep them honest: the server decides, and every burst has a cooldown.
Next: animations — making characters move.