In short
Anti-exploit in Roblox is mostly server-side validation, in Scripts in ServerScriptService. Check every RemoteEvent argument's type and range (including NaN), check the player could really do the action (distance, cooldown, ownership), and rate limit each remote per player. For movement, compare how far each character moved against its WalkSpeed and pull it back if it moved too far. Client-side anti-cheat LocalScripts can be deleted by the exploiter, so never rely on them.
- An exploiter can fire any remote with any arguments, move their own character anywhere and change any property on their own device.
- They cannot run code on your server, read ServerScriptService or ServerStorage, or change values the server holds.
- Roblox's security docs recommend quietly undoing the effect (drop the request, rubber-band the player) over kicking on a single signal.
Get the script
Server speed and teleport check
A server Script that measures how far each character moves, allows for WalkSpeed and lag, pulls players who move too far back to their last good spot, and logs repeat offenders.
-- Script in ServerScriptService named MovementCheck.
-- Pulls back characters that move further than their WalkSpeed allows (speed hacks, teleports).
local Players = game:GetService("Players")
local CHECK_SECONDS = 0.5
local SPEED_TOLERANCE = 1.5 -- allow 50% over WalkSpeed for lag and slopes
local LAG_ALLOWANCE = 6 -- extra studs per check for a late position update
local MAX_VIOLATIONS = 8 -- score at which we log the player
local DRAIN_PER_GOOD_CHECK = 0.25
type Track = { position: Vector3, score: number }
local tracks: { [Player]: Track } = {}
local function flat(v: Vector3): Vector3
return Vector3.new(v.X, 0, v.Z)
end
local function exempt(player: Player, humanoid: Humanoid): boolean
-- Server scripts that teleport a player set this first (Step 5)
local allowUntil = player:GetAttribute("AllowMoveUntil")
if type(allowUntil) == "number" and workspace:GetServerTimeNow() < allowUntil then
return true
end
-- Seats and vehicles move characters faster than WalkSpeed
return humanoid.SeatPart ~= nil
end
local function check(player: Player)
local character = player.Character
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
local root = humanoid and humanoid.RootPart
if not (character and humanoid and root and humanoid.Health > 0) then
tracks[player] = nil
return
end
local track = tracks[player]
if not track or exempt(player, humanoid) then
tracks[player] = { position = root.Position, score = if track then track.score else 0 }
return
end
local moved = (flat(root.Position) - flat(track.position)).Magnitude
local allowed = humanoid.WalkSpeed * SPEED_TOLERANCE * CHECK_SECONDS + LAG_ALLOWANCE
if moved <= allowed then
track.position = root.Position
track.score = math.max(0, track.score - DRAIN_PER_GOOD_CHECK)
return
end
-- Too far: put them back where they last were legitimately
track.score += 1
character:PivotTo(CFrame.new(track.position) * root.CFrame.Rotation)
if track.score >= MAX_VIOLATIONS then
warn(string.format("MovementCheck: %s (%d) keeps moving too fast, %.0f studs in %.1fs", player.Name, player.UserId, moved, CHECK_SECONDS))
track.score = 0
end
end
Players.PlayerRemoving:Connect(function(player: Player)
tracks[player] = nil
end)
while true do
task.wait(CHECK_SECONDS)
for _, player in Players:GetPlayers() do
check(player)
end
end
RoCode builds it in the place you have open in Roblox Studio, on Windows or macOS with a desktop browser; on a phone the button sends the prompt and the link to your computer. Free to start, with free credits every day. More Roblox Studio scripts
Where to put it
ServerScriptService
MovementCheck Script new
Settings you can change
CHECK_SECONDSIn the script- How often each character's position is checked. Default:
0.5. SPEED_TOLERANCEIn the script- How much faster than its WalkSpeed a character may move before it counts, to allow for lag and slopes. Default:
1.5. MAX_VIOLATIONSIn the script- Score at which the player is logged as a likely exploiter. Each bad check adds 1 and each good check takes 0.25 away. Default:
8.
Any server script that teleports a player must set player:SetAttribute("AllowMoveUntil", workspace:GetServerTimeNow() + 2) first, or the check pulls them back (Step 5).
What a cheater can and cannot doThis runs on the server, so an exploiter cannot turn it off. It catches speed hacks and teleports along the ground; flying and walking through walls need other checks (limits).
Type-checked with luau-lsp strict against Roblox's API definitions on 14 November 2026. Not playtested in Studio yet: press Play and watch the Output window before you publish.
Prompt for RoCode
Add a server-side movement check to my game: one Script in ServerScriptService that every half second compares how far each character moved horizontally with its WalkSpeed times 1.5 plus a lag allowance, skips seated players and players whose AllowMoveUntil attribute is in the future, pulls players who moved too far back to their last good position, and warns in the Output when a player's violation score passes 8.
On this page
What an exploiter can and cannot do
Before writing any check, know what you are defending against. An exploiter runs their own code on their own device, with the same access as your LocalScripts and a bit more. Roblox's security docs list what that includes:
| An exploiter can | An exploiter cannot |
|---|---|
| Fire any RemoteEvent or RemoteFunction, as often as they like, with any arguments | Run code on the server |
| Move their own character anywhere: teleport, fly, walk through walls | See inside ServerScriptService or ServerStorage |
| Set their own WalkSpeed, JumpPower and other properties on their device | Change a value the server holds, such as leaderstats on the server |
| Read every LocalScript and ModuleScript in ReplicatedStorage | Fire a BindableEvent in ServerStorage |
| Move unanchored parts their device simulates, and fling them at others | Change another player's saved data |
The right column is your safe ground. Anything that matters (coins, damage, who won, who owns what) should be decided by server code from server values. Then the left column mostly gets exploiters nothing.
Step 1: Validate every RemoteEvent argument
The most exploited bug in Roblox games is a remote that trusts its arguments: BuyItem:FireServer("Sword", -1000) on a shop that subtracts the price times the amount. This ModuleScript holds small checks you call at the top of every remote handler.
- Hover over ServerScriptService, click +, insert a ModuleScript and name it
Validate. - Paste the code below.
-- ModuleScript in ServerScriptService named Validate.
-- Small checks for RemoteEvent arguments. Each returns true only for a safe value.
local Validate = {}
-- A real number in a range. NaN is a number but fails every comparison, so it is checked first.
function Validate.number(value: unknown, min: number, max: number): boolean
if type(value) ~= "number" then
return false
end
if value ~= value or value == math.huge or value == -math.huge then
return false
end
return value >= min and value <= max
end
-- A whole number in a range, for amounts and indexes
function Validate.integer(value: unknown, min: number, max: number): boolean
return Validate.number(value, min, max) and math.floor(value :: number) == value
end
-- A string that is not too long, for names and item ids
function Validate.text(value: unknown, maxLength: number): boolean
return type(value) == "string" and #value > 0 and #value <= maxLength
end
-- An Instance of a class that is still in the game
function Validate.instance(value: unknown, className: string): boolean
return typeof(value) == "Instance" and value:IsA(className) and value:IsDescendantOf(game)
end
-- Is the player's character within maxDistance studs of a position?
function Validate.near(player: Player, position: Vector3, maxDistance: number): boolean
local character = player.Character
local root = character and character:FindFirstChild("HumanoidRootPart")
if not (root and root:IsA("BasePart")) then
return false
end
return (root.Position - position).Magnitude <= maxDistance
end
return Validate
Three rules the module enforces: check the type with type or typeof, because a client can send a table where you expect a number; check for NaN and infinity, because NaN > 0 and NaN < 0 are both false and slip past a range check; check an Instance is still in the game, because a client can send a part it made itself, which the server sees as nil, or a part from somewhere unexpected.
Step 2: Rate limit remotes
Even a fully checked remote can be fired 500 times a second. If each call does real work (a data store write, a raycast, a purchase check), that can lag the whole server. A rate limiter gives each player a small budget of calls that refills over time, so normal bursts pass and spam does not.
- Insert a second ModuleScript in ServerScriptService named
RateLimiter. - Paste the code below.
-- ModuleScript in ServerScriptService named RateLimiter.
-- RateLimiter.new(perSecond, burst) returns a function: call it with a player, it says yes or no.
-- Each player gets "burst" calls at once, refilled at "perSecond".
local Players = game:GetService("Players")
local RateLimiter = {}
function RateLimiter.new(perSecond: number, burst: number): (Player) -> boolean
local allowance: { [Player]: number } = {}
local lastTime: { [Player]: number } = {}
Players.PlayerRemoving:Connect(function(player: Player)
allowance[player] = nil
lastTime[player] = nil
end)
return function(player: Player): boolean
local now = os.clock()
local elapsed = now - (lastTime[player] or now)
lastTime[player] = now
local current = math.min(burst, (allowance[player] or burst) + elapsed * perSecond)
if current < 1 then
allowance[player] = current
return false
end
allowance[player] = current - 1
return true
end
end
return RateLimiter
Make one limiter per remote, because a shop and a sword need different limits. Dropping the extra calls quietly is usually enough; a player who keeps hitting the limit for minutes is worth a log line (Step 6).
Step 3: A remote that uses both
Here is a melee attack remote built the safe way. The client only says which enemy it swung at. The server checks the enemy is real, close enough and alive, limits the swings per second, and picks the damage itself.
-- Script in ServerScriptService named AttackHandler.
-- The client fires Attack with the enemy Model it swung at. The server decides the rest.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerScriptService = game:GetService("ServerScriptService")
type ValidateModule = {
instance: (value: unknown, className: string) -> boolean,
near: (player: Player, position: Vector3, maxDistance: number) -> boolean,
}
local Validate = require(ServerScriptService:WaitForChild("Validate")) :: ValidateModule
local RateLimiter = require(ServerScriptService:WaitForChild("RateLimiter")) :: {
new: (perSecond: number, burst: number) -> (Player) -> boolean,
}
local DAMAGE = 15 -- the server's number, never the client's
local REACH = 10 -- studs, a little more than the weapon really reaches, for lag
local attack = Instance.new("RemoteEvent")
attack.Name = "Attack"
attack.Parent = ReplicatedStorage
local canSwing = RateLimiter.new(3, 3) -- 3 swings a second, bursts of 3
attack.OnServerEvent:Connect(function(player: Player, target: unknown)
if not canSwing(player) then
return
end
if not Validate.instance(target, "Model") then
return
end
local enemy = target :: Model
local humanoid = enemy:FindFirstChildOfClass("Humanoid")
local root = enemy:FindFirstChild("HumanoidRootPart")
if not (humanoid and humanoid.Health > 0 and root and root:IsA("BasePart")) then
return
end
-- Players cannot hit themselves
if enemy == player.Character then
return
end
if not Validate.near(player, root.Position, REACH) then
return
end
humanoid:TakeDamage(DAMAGE)
end)
Compare that with the copied-script version, Attack:FireServer(enemy, 15), where the server applies whatever damage the client sends. An exploiter sends math.huge and one-shots every boss from across the map. The combat system guide builds a full server-side hitbox on the same idea, and the RemoteEvents guide covers the client side.
Step 4: Check speed and teleports
Each player's device simulates their own character, which is why exploiters can move it however they like. The server still receives the position. So the server can measure how far each character moved since the last check and compare it with how far it could have moved.
Roblox's movement validation docs give the shape of a good check: measure on the flat XZ plane, so falling and jumping never count; allow for lag, because positions arrive in bursts; and use a leaky bucket, a score that rises on bad checks and drains on good ones, so one lag spike is not a strike. On a bad check, pull the player back to their last good position (rubber-banding) instead of kicking.
-- Script in ServerScriptService named MovementCheck.
-- Pulls back characters that move further than their WalkSpeed allows (speed hacks, teleports).
local Players = game:GetService("Players")
local CHECK_SECONDS = 0.5
local SPEED_TOLERANCE = 1.5 -- allow 50% over WalkSpeed for lag and slopes
local LAG_ALLOWANCE = 6 -- extra studs per check for a late position update
local MAX_VIOLATIONS = 8 -- score at which we log the player
local DRAIN_PER_GOOD_CHECK = 0.25
type Track = { position: Vector3, score: number }
local tracks: { [Player]: Track } = {}
local function flat(v: Vector3): Vector3
return Vector3.new(v.X, 0, v.Z)
end
local function exempt(player: Player, humanoid: Humanoid): boolean
-- Server scripts that teleport a player set this first (Step 5)
local allowUntil = player:GetAttribute("AllowMoveUntil")
if type(allowUntil) == "number" and workspace:GetServerTimeNow() < allowUntil then
return true
end
-- Seats and vehicles move characters faster than WalkSpeed
return humanoid.SeatPart ~= nil
end
local function check(player: Player)
local character = player.Character
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
local root = humanoid and humanoid.RootPart
if not (character and humanoid and root and humanoid.Health > 0) then
tracks[player] = nil
return
end
local track = tracks[player]
if not track or exempt(player, humanoid) then
tracks[player] = { position = root.Position, score = if track then track.score else 0 }
return
end
local moved = (flat(root.Position) - flat(track.position)).Magnitude
local allowed = humanoid.WalkSpeed * SPEED_TOLERANCE * CHECK_SECONDS + LAG_ALLOWANCE
if moved <= allowed then
track.position = root.Position
track.score = math.max(0, track.score - DRAIN_PER_GOOD_CHECK)
return
end
-- Too far: put them back where they last were legitimately
track.score += 1
character:PivotTo(CFrame.new(track.position) * root.CFrame.Rotation)
if track.score >= MAX_VIOLATIONS then
warn(string.format("MovementCheck: %s (%d) keeps moving too fast, %.0f studs in %.1fs", player.Name, player.UserId, moved, CHECK_SECONDS))
track.score = 0
end
end
Players.PlayerRemoving:Connect(function(player: Player)
tracks[player] = nil
end)
while true do
task.wait(CHECK_SECONDS)
for _, player in Players:GetPlayers() do
check(player)
end
end
- allowed uses the WalkSpeed the server sees. If a game pass or sprint sets WalkSpeed on the server, the check follows it. An exploiter who raises WalkSpeed only on their own device does not change the server's value.
- PivotTo moves the whole character back, keeping the way it faces. The player feels a snap back, which is usually enough to make a speed hack useless.
- The score only logs. Deciding to kick or ban is Step 6.
- If your game has a dash, a speed pad or a sprint set on the client, raise
SPEED_TOLERANCEor exempt those moments the same way as teleports, or honest players get pulled back.
Step 5: Let your own teleports through
Your own teleporters, respawns at checkpoints and round starts also move characters far in one step. Before any server script moves a player, it sets an attribute that tells MovementCheck to skip them for a moment:
-- In any server Script that teleports a player
local Players = game:GetService("Players")
local function teleportPlayer(player: Player, destination: CFrame)
local character = player.Character
if not character then
return
end
-- MovementCheck skips this player for the next 2 seconds
player:SetAttribute("AllowMoveUntil", workspace:GetServerTimeNow() + 2)
character:PivotTo(destination)
end
Players.PlayerAdded:Connect(function(player: Player)
player.CharacterAdded:Connect(function()
task.wait(5)
teleportPlayer(player, CFrame.new(0, 10, 0)) -- e.g. into the arena
end)
end)
The attribute is set on the server, so an exploiter cannot use it: they can change attributes on their own copy of the Player, but MovementCheck reads the server's copy. Respawning is already handled, because a new character starts a fresh track. The teleporter guide and checkpoint guide are the usual places to add the line.
Step 6: What to do when you catch someone
Roblox's detection docs describe a ladder, from quiet to visible. Climb it slowly, because every check has false positives: a laggy phone, a physics glitch that flings someone, a shortcut you did not know about.
| Step | Example in this guide |
|---|---|
| Silent logging | The warn in MovementCheck when the score passes MAX_VIOLATIONS |
| Quiet mitigation | Dropping a bad remote call; rubber-banding a speed hack |
| Temporary restrictions | Turning off trading or leaderboard entry for that player |
| Visible enforcement | player:Kick(), or Players:BanAsync() for repeat offenders |
One high-confidence signal is a honeypot: a remote that no script of yours ever fires, with a tempting name. Only an exploiter browsing your remotes would call it, so logging and kicking on it is safe:
-- Script in ServerScriptService named Honeypot.
-- A remote nothing in the game uses. Anyone who fires it is poking at remotes with an exploit.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local bait = Instance.new("RemoteEvent")
bait.Name = "AdminGiveCoins"
bait.Parent = ReplicatedStorage
bait.OnServerEvent:Connect(function(player: Player)
warn("Honeypot fired by " .. player.Name .. " (" .. player.UserId .. ")")
player:Kick("Disconnected")
end)
Never fire it from your own code, and never name a real remote that way. For permanent action, Players:BanAsync stops a player rejoining across your experience; the docs recommend it for persistent offenders over repeated kicks. Prefer bans with a duration while you are still tuning your checks.
What a server script cannot stop
Be honest with yourself about the gaps, so you design around them:
- Flying and noclip. The speed check ignores height, so flying slowly passes. Walking through walls at normal speed passes too. Checking these needs raycasts against your map, and many games accept the gap instead.
- Aimbots and auto-clickers. They send exactly what a perfect player would. Rate limits cap the damage; cadence checks (identical timing every click) are a weak signal at best.
- Reading what the client can see. Anything you send to the client, an exploiter can read: the answer to a quiz, the location of a hidden item. Keep secrets on the server until they are needed.
- Physics on unanchored parts. A device that simulates a part can throw it anywhere. Give gameplay-critical parts server ownership with
SetNetworkOwner(nil), as the moving platform guide does.
For movement, Roblox's docs point to its server authority model as the most reliable fix: the server simulates movement and physics and clients only send their inputs. It is switched on in Studio by setting AuthorityMode on Workspace to Server, which changes how the whole game runs, so read Roblox's server authority page and check its current status before moving a finished game to it.
Common errors and fixes
Most problems with anti-exploit checks are honest players being caught.
Players get pulled back when they use a teleporter
The teleport script must set AllowMoveUntil before it moves them (Step 5). Teleports done from a LocalScript cannot set the server's attribute; move them to the server.
Players get pulled back while sprinting or dashing
Sprint scripts usually change WalkSpeed on the client, so the server still sees 16. With the defaults a character may still cover 18 studs every half second, about 36 studs a second, so a normal sprint passes. A dash can go further: raise LAG_ALLOWANCE, or have the server set AllowMoveUntil when it allows a dash. The sprint guide has a matching check that knows about its own sprint and dash.
Players in cars get pulled back
MovementCheck skips seated players through humanoid.SeatPart. A vehicle that moves the character without a Seat needs its own exemption.
Requested module experienced an error while loading
One of the ModuleScripts has a typo or is not a ModuleScript. See that error's page.
Build it with RoCode
If you would rather have these checks added to your existing remotes, RoCode can do it in the place you have open. RoCode is an independent AI agent for Roblox Studio, not made by Roblox: you describe the change in a web chat, and its Studio plugin edits the scripts in your Explorer.
Go through every RemoteEvent in my game, add type, range and distance checks and a rate limit on the server, and add a speed check that pulls back players who move too fast.
- Can read your place first to find every remote and the server handler for each
- Edits the scripts and is told to compile-check each one with Check Script
- Sets an undo point before and after each batch of changes, so Ctrl+Z steps back one batch at a time
Review each change: only you know which client inputs your game legitimately sends. How RoCode connects to Studio.
Questions
How do I make an anti-exploit in Roblox Studio?
Check everything on the server: RemoteEvent argument types and ranges, distances and cooldowns, a rate limit per remote, and a speed check on character movement. Steps 1 to 4 build each one.
Can you stop exploiters in Roblox completely?
No. They control their own device. You can make sure their changes get them nothing by keeping every important decision on the server.
Does a client-side anti-cheat work in Roblox?
Not reliably. An exploiter can delete or edit any LocalScript. Roblox's docs say to try never to ban based on client-side detections.
How do I stop speed hackers in Roblox?
On the server, compare how far each character moved on the flat plane with its WalkSpeed, allow for lag, and move it back if it went too far. The MovementCheck script does this.
How do I secure RemoteEvents?
Never trust arguments: check their type, NaN, range and that the player could really do the action, and decide amounts like damage or prices on the server.
Sources and further reading
- Roblox Creator Docs: Security tactics. never trust the client, the server as source of truth
- Roblox Creator Docs: Securing the client-server boundary. validating remote arguments and rate limits
- Roblox Creator Docs: Network ownership and movement validation. what a client controls, XZ projection and leaky buckets
- Roblox Creator Docs: Server-side detection. rubber-banding, honeypots and the consequence ladder
- Roblox Creator Docs: Server authority model. AuthorityMode and how server-side movement works
How the code was checked: every script on this page passes Luau's strict type checker against Roblox's API definitions (luau-lsp, 14 November 2026). A type check catches misspelt APIs and wrong types, not game logic, so playtest in Studio before you publish.