Roblox client-server networking and anti-exploit: RemoteEvent and RemoteFunction contracts, server authority, rate limits, hit validation and replication. Use…
Roblox networking
The server decides authoritative state; clients send input or intent. This skill owns the request
contract across that boundary: what is sent, who validates it, who receives the result, and how it
is tested with more than one client.
Workflow
Inventory the existing protocol. Find every remote and both endpoints before adding one:
rg -n "OnServerEvent|OnServerInvoke|OnClientEvent|InvokeClient|FireAllClients" src
(or the Studio MCP script_grep tool). For each, note direction, sender, payload, frequency,
validation, and consumers. Reuse the canonical remote folder; a duplicate remote created because
discovery was skipped usually means two handlers apply the same action.
Classify each message. Client request, server fact, or ephemeral cosmetic sample. Pick
reliable event, unreliable event, or request/response from that, not from convenience.
Minimize the payload. Send stable IDs and intent. Never send a price, damage, ownership
result, arbitrary path, or any outcome the server can derive.
Validate in layers, cheapest first. Rate budget, type/shape/finiteness, allowlisted value,
Instance class and ancestry, player permission and state, distance or line of sight, cooldown.
Only then do expensive work.
Apply on the server. The server resolves targets and mutates health, inventory, currency,
cooldowns, and progression. Client checks are UX only.
Replicate narrowly. FireClient for private or local facts; broadcast only shared facts.
Replicated properties are already a state channel, so do not mirror them through remotes.
Handle time and lifecycle. Requests arrive after death, respawn, streaming changes, or
disconnect. Resolve the current character during handling and clear per-player tables on
PlayerRemoving.
Run the abuse matrix and capture Output from every side. With the Studio MCP server
connected (list_roblox_studios returns a place), start play with start_stop_play, drive the
pure validator from execute_luau on the Server datamodel with valid, malformed, NaN, wrong
Instance and burst inputs, then read get_console_output. start_stop_play is one solo client,
so for targeted versus broadcast delivery and two-player cases ask the user to run Server &
Clients with two clients and paste the server and both client Output panes. Report each case as
executed, prepared but not run, or unverified.
Choose the transport
Primitive
Use
Do not use
RemoteEvent
ordered, reliable one-way requests and facts
continuous samples where newer replaces older
UnreliableRemoteEvent
ephemeral cosmetic or continuous state that tolerates loss and reordering
purchases, damage, inventory, one-shot transitions
RemoteFunction
bounded client-to-server query that truly needs a reply
server-to-client invocation, long work, ordinary commands
Never InvokeClient from the server: a client that errors makes the server error, a client that
leaves makes it throw, and a client that never returns makes it yield forever. Use FireClient
plus a separate response event.
Delivery rules that change handler design (per connection, per direction):
RemoteEvent messages arrive in send order, even across different RemoteEvents, but order
covers when each handler starts. A handler that yields (task.wait, WaitForChild, a
DataStore call) lets the next message from the same player start before it resumes, so
check-then-yield-then-apply code can approve two requests. Claim the cooldown or mark the
request in progress before the first yield.
A client firing a RemoteEvent faster than the throttle is delayed, not dropped; the backlog
still arrives. UnreliableRemoteEvent traffic over the throttle or size cap, or with no handler
connected, is discarded.
Messages sent before a handler connects are queued (bounded) for RemoteEvents and
RemoteFunctions. There is no ordering guarantee between a RemoteFunction and a
RemoteEvent; use one remote type or your own sequence number when order matters.
The client-to-server throttle is shared by every remote of the same type in the experience, so a
legitimate player sending per-frame reliable events hits it before any attacker does.
Pattern: validate before resolving gameplay
-- ServerScriptService/CombatRequests.server.luau
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local attack = ReplicatedStorage.Remotes.Attack
local lastRequest: {[Player]: number} = {}
local RANGE = 12
local COOLDOWN = 0.25
attack.OnServerEvent:Connect(function(player: Player, target: unknown)
local now = Workspace:GetServerTimeNow()
if now - (lastRequest[player] or -math.huge) < COOLDOWN then return end
lastRequest[player] = now
if typeof(target) ~= "Instance" or not target:IsA("Model") then return end
if not target:IsDescendantOf(Workspace.Characters) then return end
local targetHumanoid = target:FindFirstChildOfClass("Humanoid")
local targetRoot = target:FindFirstChild("HumanoidRootPart")
local character = player.Character
local root = character and character:FindFirstChild("HumanoidRootPart")
local humanoid = character and character:FindFirstChildOfClass("Humanoid")
if not targetHumanoid or not targetRoot or not root or not humanoid then return end
if humanoid.Health <= 0 or targetHumanoid.Health <= 0 then return end
if (root.Position - targetRoot.Position).Magnitude > RANGE then return end
if not serverCombatStateAllowsAttack(player, now) then return end
targetHumanoid:TakeDamage(serverDamageFor(player))
end)
Players.PlayerRemoving:Connect(function(player)
lastRequest[player] = nil
end)
One distance check is not security. A real melee system also needs server-known attack windows,
shape or line-of-sight checks, team rules, and a lag policy.
Hit validation for ranged weapons. The client may report "I fired at time T toward D". The
server rebuilds the shot from server-known state: muzzle origin near the server's character
position, fire rate from the weapon's cooldown, ammo, and a direction within a tolerance of the
claim. Then the server runs its own raycast (query API in roblox-physics). Decide the lag policy
explicitly: either accept hits within a bounded rewind window using recorded target positions, or
accept only what the server sees now. Never accept the client's hit Instance or hit position as
the result.
Pattern: token bucket at the boundary
type Bucket = {tokens: number, updatedAt: number}
local buckets: {[Player]: Bucket} = {}
local CAPACITY, REFILL_PER_SECOND = 6, 3
local function consume(player: Player, cost: number): boolean
local now = os.clock()
local bucket = buckets[player] or {tokens = CAPACITY, updatedAt = now}
bucket.tokens = math.min(CAPACITY,
bucket.tokens + (now - bucket.updatedAt) * REFILL_PER_SECOND)
bucket.updatedAt = now
if bucket.tokens < cost then buckets[player] = bucket; return false end
bucket.tokens -= cost
buckets[player] = bucket
return true
end
Assign cost by server impact. Reject cheaply before DataStore calls, cloning, raycasts, or broad
replication. Log aggregate abuse signals, not one warning per rejected packet. Clear the bucket on
PlayerRemoving.
Replication, streaming, and prediction
With instance streaming, a valid server Instance may not exist on a client. Send a stable ID and
tolerate absence; do not wait forever for optional streamed content.
Make each unreliable sample self-contained and add a sequence number or timestamp so receivers
drop older arrivals. Never split one required transition across several unreliable messages.
Without Server Authority, predict only latency-sensitive, reversible presentation. Tag client
commands with a sequence ID; the server returns authoritative state plus an acknowledgement and
the client corrects smoothly. Prediction never awards damage, currency, inventory, or progression.
Network ownership makes a client responsive but lets it influence physics. Ownership is not
authorization: validate consequences on the server.
Places that use Server Authority
Read Workspace.AuthorityMode first (Properties panel, the place file, or execute_luau). When it
is Server, the engine supplies client prediction, rollback, and resimulation, and gameplay
objects can stay server-owned without input lag. Work with it instead of building a parallel
scheme:
Put core gameplay in a ModuleScript required by both a server Script and a client
LocalScript, with logic in RunService:BindToSimulation() callbacks. Only members labelled
Simulation Access work there. Use time() (synchronized and rewound during resimulation), not
os.clock(), tick(), or os.time().
Send simulation-affecting input through InputActions (their InputContext must sit under the
owning Player), not UserInputService events. Keep synchronized custom state in Attributes on
predicted instances and write them only inside bound functions.
Destroy() and reparenting are not allowed inside bound functions. Record the intent in an
Attribute and remove the instance in a server PostSimulation connection. Humanoid:EquipTool()
is not simulation-safe either, so equippable items are welded Models tracked by an Attribute.
Remotes still carry discrete facts and requests, but they are not ordered with property and
attribute replication. Play effects and sounds from RenderStepped reading simulation results,
so a mispredicted frame does not trigger them twice, and make them undoable.
RunService:SetPredictionMode() (client-only) forces prediction per instance, and
RunService:GetPredictionStatus() shows what is predicted. Test with Studio's Network Simulator
(latency, jitter, loss).
Server Authority is a project-wide migration. Do not switch AuthorityMode on an existing place as
a side effect of another task; report it as an option instead.
Gotchas
Symptom
Likely cause
Remedy
exploiter chooses damage or price
outcome accepted from client
send intent or ID; derive and apply on server
arbitrary object can be deleted
only typeof(x) == "Instance" checked
validate class, ancestry, ownership, state, and an allowlisted operation
server stalls on one player
server calls InvokeClient
replace with events
honest player is throttled
per-frame reliable messages
lower rate, rely on replication, batch, or use unreliable cosmetics
old packet reverses a newer effect
unreliable samples treated as commands
version samples; use a reliable event for transitions
remote breaks after respawn
cached character or root
resolve the current character in the handler; reject stale state
private data leaks
FireAllClients by default
FireClient with a minimal payload
distance check bypassed
client-owned part moved near target
server-own critical parts; validate with server-observed state
one cooldown lets two requests through
handler yields between check and apply
claim cooldown or in-progress state before the first yield
effect plays twice under Server Authority
effect triggered inside resimulated code
trigger from RenderStepped reading simulation state
"lag" report
could be frame time, not network
check the MicroProfiler (or Studio's rbx-perf-profiling skill) before redesigning remotes
Resources
Read references/validation-and-testing.md when writing or changing a remote contract, or
investigating an exploit or desync: payload rules, validation order, and the full multi-client
abuse matrix.
Related skills
roblox-luau: execution locations and basic remote mechanics.
roblox-characters: respawn-safe character resolution.
roblox-physics: raycast and overlap APIs, network ownership mechanics.
roblox-studio-workflow: Server & Clients testing, Studio MCP, and honest evidence.
Version notes
Last verified: 2026-11-11.
UnreliableRemoteEvent payloads over 1,000 bytes are dropped; Studio Output reports the overage.
Client-to-server throttle: about 500 requests per second per client, shared by all remotes of the
same type (RemoteEvent and UnreliableRemoteEvent each have their own pool).
Server Authority reached full release in July 2026 (opt-in). Setting AuthorityMode = Server
also requires next-generation replication, PlayerScriptsUseInputActionSystem, deferred
SignalBehavior, UseFixedSimulation, and StreamingEnabled. The release stopped synchronizing
the Camera InputAction; use Player:GetCameraState(). Replicated attributes on predicted
instances: the first 64 per instance, names and string values up to 50 characters. Tools are not
fully supported yet.
Studio's Network Simulator was a Studio beta (File → Beta Features → New Device Simulator).
To re-check: append .md to any Creator Hub docs URL, or start from
https://create.roblox.com/docs/llms.txt. With Studio MCP connected, http_get and the
built-in rbx-docs-search skill fetch the same pages.
Sources: https://create.roblox.com/docs/scripting/events/remote,
https://create.roblox.com/docs/reference/engine/classes/UnreliableRemoteEvent,
https://create.roblox.com/docs/projects/server-authority,
https://create.roblox.com/docs/scripting/security/client-server-boundary,
https://create.roblox.com/docs/physics/network-ownership,
https://create.roblox.com/docs/studio/testing-modes,
https://devforum.roblox.com/t/full-release-ship-fair-and-competitive-games-with-server-authority/4727993.
39:[don't have the plugin yet? install it then click "run inline in claude" again.
this skill owns the request contract across the client-server boundary: what gets sent, who validates it, who receives the result, and how to test it with multiple clients. the server decides authoritative state; clients send input or intent only. use this skill whenever you create a remote, audit existing remotes for exploit vectors, design hit validation for weapons, or implement rate limiting and replication rules.
external connections and config
list_roblox_studios)script_grep (or rg -n in source) to inventory remotes, execute_luau to run validation tests on the datamodel, start_stop_play to run solo play tests, get_console_output to read server and client Output panesexecute_luau before designing remotes (opt-in since July 2026; requires next-generation replication, PlayerScriptsUseInputActionSystem, deferred SignalBehavior, UseFixedSimulation, and StreamingEnabled)game state context
inputs: place file, source code
steps:
1a. search for every remote endpoint:
rg -n "OnServerEvent|OnServerInvoke|OnClientEvent|InvokeClient|FireAllClients|FireClient|Fire" src
or use Studio MCP script_grep tool.
1b. for each remote found, record: direction (client-to-server or server-to-client), sender, payload, expected frequency, validation logic, and all handlers that consume it.
1c. reuse the canonical remote folder (e.g., ReplicatedStorage.Remotes). duplicate remotes created because discovery was skipped usually means two handlers apply the same action.
1d. classify each message as one of three types:
1e. pick the transport based on classification:
| transport | use | do not use |
|---|---|---|
| RemoteEvent | ordered, reliable one-way requests and facts | continuous samples where newer replaces older |
| UnreliableRemoteEvent | ephemeral cosmetic or continuous state that tolerates loss and reordering | purchases, damage, inventory, one-shot transitions |
| RemoteFunction | bounded client-to-server query that truly needs a reply | server-to-client invocation, long work, ordinary commands |
never use InvokeClient from the server: a client that errors makes the server error, a client that leaves makes it throw, and a client that never returns makes the server yield forever. use FireClient plus a separate response RemoteEvent instead.
outputs: inventory table with remote name, direction, payload schema, classification, and chosen transport.
inputs: remote classification, server validation rules
steps:
2a. send stable IDs and intent, never computed outcomes. do not send: price, damage, ownership result, arbitrary path, or any value the server can derive.
example: client sends targetModelInstance and attackTime, not {targetId = 5, damage = 25}.
2b. minimize bytes: use a stable ID number instead of a string key when possible, pack booleans into a bitfield for high-frequency samples.
2c. for unreliable messages, include a sequence number or server timestamp so receivers drop older arrivals. never split one required transition (e.g., death, inventory drop) across several unreliable messages.
outputs: payload schema with field names, types, size constraints, and rationale for each field.
inputs: payload, player, current character, game state, allowlist or config
steps:
3a. apply checks in this order:
typeof(x) == "Instance", finiteness checks for numbers, table structuretarget:IsA("Model"), target:IsDescendantOf(Workspace.Characters)3b. reject the request and return early at each layer if a check fails. do not proceed to the next layer.
3c. before the first task.yield() or WaitForChild(), claim the cooldown or mark the request in progress (write to a table or set an attribute). this prevents check-then-yield-then-apply race conditions where two requests pass validation before either one applies.
outputs: validation order list and code comments marking the boundary between cheap and expensive checks.
inputs: validated request, player character, current gameplay state
steps:
4a. resolve the current character during handler execution. do not cache player.Character or player.Character.HumanoidRootPart across yields.
4b. apply all mutations on the server: health, inventory, currency, cooldown, progression, state machine. client-side checks are UX only.
4c. handle the case where the request arrives after death, respawn, streaming changes, or disconnect: validate that the character still exists and is in the correct state.
4d. clear per-player tables (cooldowns, in-progress flags, buckets) on Players.PlayerRemoving.
outputs: mutated game state, side effects (replication fire, datastore write).
inputs: fact to replicate (private state or shared state), set of target players
steps:
5a. decide whether the fact is private (e.g., player's inventory, quest log) or shared (e.g., character position, health).
5b. for private facts, use remote:FireClient(player, ...). for shared facts, use remote:FireAllClients(...) only if all players benefit from knowing it; otherwise use targeted FireClient calls.
5c. do not use remotes to mirror replicated properties (e.g., Humanoid.Health, attributes on predicted instances). replicated properties are already a state channel.
5d. for unreliable continuous state (e.g., animation frame), make each sample self-contained and include a sequence number or timestamp so receivers drop older arrivals.
outputs: replication calls with correct targets and payload.
inputs: current time, player, character state, instance streaming config
steps:
6a. use Workspace:GetServerTimeNow() for time-sensitive checks (cooldown, rate limit). use time() only inside RunService:BindToSimulation() callbacks when Server Authority is enabled (it is synchronized and rewound during resimulation).
6b. resolve the current character and character parts (HumanoidRootPart, Humanoid) during handler execution. reject requests that reference a stale or missing character.
6c. with instance streaming enabled, a valid server instance may not exist on a client. send a stable ID and tolerate absence; do not WaitForChild() on optional streamed content.
6d. clear per-player state (cooldown tables, in-progress flags, buckets) in a Players.PlayerRemoving connection.
outputs: handlers that resolve fresh state each call and clean up on player removal.
inputs: client fire report (time, direction, muzzle position), server-known state (weapon config, ammo, character position), recorded target positions (optional)
steps:
7a. the client may report "I fired at time T toward direction D". the server rebuilds the shot from server-known state: muzzle origin near the server's character position, fire rate from the weapon's cooldown, ammo, and a direction within a tolerance of the claim.
7b. decide the lag policy explicitly:
7c. run the server's own raycast query (see roblox-physics skill). never accept the client's hit instance or hit position as the result.
7d. apply the hit on the server only (call :TakeDamage(), update inventory, etc.).
outputs: hit validation result (hit, miss, or hit-but-too-old) and applied mutation.
inputs: player, action cost (default 1), capacity, refill rate
steps:
8a. maintain a token bucket per player:
type Bucket = {tokens: number, updatedAt: number}
local buckets: {[Player]: Bucket} = {}
local CAPACITY, REFILL_PER_SECOND = 6, 3
local function consume(player: Player, cost: number): boolean
local now = os.clock()
local bucket = buckets[player] or {tokens = CAPACITY, updatedAt = now}
bucket.tokens = math.min(CAPACITY,
bucket.tokens + (now - bucket.updatedAt) * REFILL_PER_SECOND)
bucket.updatedAt = now
if bucket.tokens < cost then buckets[player] = bucket; return false end
bucket.tokens -= cost
buckets[player] = bucket
return true
end
8b. call consume(player, cost) at the start of the handler, before any validation.
8c. assign cost by server impact: cheaply (cost 1) for reads and cheap checks, medium (cost 2-3) for physics or replication, high (cost 5+) for datastore calls or cloning.
8d. log aggregate abuse signals (e.g., "player X exceeded rate limit 10 times in 60 seconds"), not one warning per rejected packet.
8e. clear the bucket on Players.PlayerRemoving.
outputs: rate limit decision (accept or reject) before expensive work.
inputs: place with remotes, Studio MCP or Studio running, two or more test clients
steps:
9a. solo play (one client): with Studio MCP server connected (list_roblox_studios), start play with start_stop_play, then use execute_luau on the Server datamodel to fire test inputs:
read the result and server Output with get_console_output. capture whether the server crashes, the client crashes, or the state mutates unexpectedly.
9b. multi-client play (two or more clients): ask the user to run Server & Clients (Studio mode), connect two or more test clients, and paste the server and all client Output panes. drive the same test cases above, plus:
FireAllClients reveal private data to the wrong player?9c. for each test case, record: executed, prepared but not run, or unverified (and why).
outputs: test matrix with inputs, expected results, and actual results (from Output panes).
inputs: Workspace.AuthorityMode, place config (PlayerScriptsUseInputActionSystem, UseFixedSimulation, etc.)
steps:
10a. check Workspace.AuthorityMode first (Properties panel or execute_luau). if it is not "Server", skip to step 10d.
10b. if AuthorityMode = Server is set, the engine supplies client prediction, rollback, and resimulation. put core gameplay in a ModuleScript required by both a server Script and a client LocalScript, with logic in RunService:BindToSimulation() callbacks. only members labelled "Simulation Access" work inside bound functions.
10c. use time() (synchronized and rewound during resimulation), not os.clock(), tick(), or os.time(). send simulation-affecting input through InputActions (their InputContext must sit under the owning Player), not UserInputService events. keep synchronized custom state in Attributes on predicted instances and write them only inside bound functions.
10d. Destroy() and reparenting are forbidden inside bound functions. record the intent in an attribute and remove the instance in a server PostSimulation connection. Humanoid:EquipTool() is not simulation-safe; equippable items are welded Models tracked by an Attribute.
10e. remotes still carry discrete facts and requests, but they are not ordered with property and attribute replication. play effects and sounds from RenderStepped reading simulation results, so a mispredicted frame does not trigger them twice, and make them undoable.
10f. use RunService:SetPredictionMode() (client-only) to force prediction per instance, and RunService:GetPredictionStatus() to check what is predicted. test with Studio's Network Simulator (latency, jitter, loss).
10g. server authority is a project-wide migration: do not switch AuthorityMode on an existing place as a side effect of another task; report it as an option instead.
outputs: simulation-safe code using time(), InputActions, and Attributes; effects triggered from RenderStepped; test results with Network Simulator.
if the client sends damage or a price, do what? reject the request. the client sent an outcome instead of intent or a stable ID. send only the target ID and attackTime; derive damage on the server from the weapon config and the player's stats.
if only typeof(x) == "Instance" is checked, do what?
add more layers: validate instance class (:IsA("Model")), ancestry (:IsDescendantOf()), ownership (does the player own it?), and operation allowlist. arbitrary objects can be deleted if validation is incomplete.
if the server calls InvokeClient, what happens?
the server may stall or throw. a client that errors makes the server error, a client that leaves makes it throw, and a client that never returns makes the server yield forever. replace with FireClient plus a separate response RemoteEvent.
if a handler yields between check and apply, what happens?
two requests may pass validation for the same cooldown or in-progress state. claim the cooldown or mark the request in progress before the first task.wait(), WaitForChild(), or datastore call.
if a client sends per-frame reliable messages, do what?
the honest player hits the shared throttle (about 500 requests per second, shared by all RemoteEvent and UnreliableRemoteEvent instances) before any attacker does. lower the message rate, rely on replicated properties instead of remotes, batch messages, or use UnreliableRemoteEvent for continuous cosmetic samples.
if an unreliable sample is treated as a command (not versioned), what happens? an old packet can reverse a newer effect. add a sequence number or timestamp to each unreliable sample and drop arrivals older than the latest received. use a reliable event for one-shot transitions (death, respawn).
if a remote breaks after respawn, do what?
resolve the current character in the handler; do not cache player.Character or player.Character.HumanoidRootPart across yields. reject requests that reference a stale character.
if private data is replicated to all clients, do what?
use FireClient(player, ...) for private state (inventory, quest log, stats) instead of FireAllClients(...). only broadcast facts that all players benefit from knowing.
if a distance check is bypassed by moving a client-owned part near the target, do what? server-own critical parts (HumanoidRootPart for characters) or validate with server-observed state only. the client cannot be trusted to move parts that affect validation.
if replication order is uncertain between a RemoteFunction and RemoteEvent, do what? use one remote type or add a sequence number when order matters. there is no ordering guarantee between a RemoteFunction and a RemoteEvent.
if a player reports "lag" and you redesigned remotes but the frame time is high, do what? check the MicroProfiler (or rbx-perf-profiling skill) first. frame time and network lag are different; redesigning remotes does not fix a CPU bottleneck.
if Server Authority is set but the place file lacks next-generation replication config, do what? report it as an incomplete migration. AuthorityMode = Server also requires PlayerScriptsUseInputActionSystem, deferred SignalBehavior, UseFixedSimulation, and StreamingEnabled. do not force it on an existing place as a side effect of another task.
a runnable remote handler passes the abuse matrix: