Roblox networking
Build explicit request and replication contracts in which the server decides authoritative game
state and clients provide input or intent. Targets Roblox's rolling platform APIs. This skill goes
deeper than the networking primer in roblox-luau.
When to use
- Use to design, implement, debug, or secure cross-boundary Roblox communication.
- Use when a remote trusts client values, an exploiter can target arbitrary Instances, messages
spam services, streamed objects are missing, or clients disagree with the server.
When not to use: basic Luau/services belong to roblox-luau; persistent state belongs to
roblox-datastores; physical ownership mechanics also compose with roblox-physics.
Workflow
- Inspect the existing protocol. Find every remote and both endpoints; document direction,
sender, payload, frequency, authority, validation, and consumers. Reuse the canonical remote
folder—do not create a duplicate because discovery was skipped.
- Classify each message. Client request, server fact, or ephemeral cosmetic sample. Choose
reliable event, unreliable event, or request/response from semantics—not convenience.
- Minimize the payload. Send stable identifiers and intent. Do not send a price, damage,
ownership result, arbitrary path, or computed outcome the server can derive.
- Validate in layers. Check type/shape/finiteness, allowlisted value, Instance class and
ancestry, player permissions/state, distance/line of sight where relevant, server cooldown,
and rate budget before doing expensive work.
- Apply on the server. The server resolves targets and mutates health, inventory, currency,
cooldowns, and progression. Client-side checks improve UX but grant no trust.
- Replicate narrowly. Use
FireClient for private or local facts; broadcast only shared facts.
Avoid sending replicated properties again unless the client needs a distinct presentation event.
- Handle time and lifecycle. Requests may arrive after death, respawn, streaming changes, or
disconnect. Resolve the current character/state during handling and clean per-player limiter data.
- Verify with Server & Clients. Exercise normal, malformed, spam, out-of-range, stale
character, rapid respawn, leaving, simultaneous players, targeted, and broadcast cases. Inspect
server and each client Output separately.
Choose the transport
| Primitive |
Use |
Do not use |
RemoteEvent |
ordered, reliable one-way requests/facts |
continuous samples where newer replaces older |
UnreliableRemoteEvent |
ephemeral cosmetic/continuous state tolerant of loss and reordering |
purchases, damage decisions, inventory, one-shot state transitions |
RemoteFunction |
bounded client-to-server query that truly needs an immediate reply |
server-to-client invocation; long/uncertain work; ordinary commands |
Never invoke a client synchronously from the server. A client may disconnect, error, or never
return. Prefer server RemoteEvent:FireClient() and a separate response event when needed.
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)
This is still only a compact example: a real melee system may require server-known attack windows,
line-of-sight/shape checks, team rules, and lag policy. Do not treat one distance check as security.
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.
Replication, streaming, and prediction
- Replicated Instances/properties are already a state channel. Use remotes for intent, private
state, or presentation cues, not an unconditional parallel copy of the DataModel.
- 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.
- High-rate cosmetic data may use
UnreliableRemoteEvent; make each sample self-contained because
delivery and order are not guaranteed. Payloads over 1000 bytes are dropped (Studio Output
reports the overage). RemoteEvent and UnreliableRemoteEvent also share a throttle of roughly
500 calls/second per client, counted across all remotes of that type — which is what a
legitimate player hits before any attacker does.
- Predict only latency-sensitive reversible presentation. Include a client sequence/command ID;
the server returns authoritative state and acknowledgement; the client corrects smoothly. Never
let prediction award damage, currency, inventory, or progression.
- Network ownership improves responsiveness but lets that client influence physical simulation.
Validate gameplay consequences on the server; ownership is not authorization.
Common failures
| Symptom |
Likely cause |
Remedy |
| exploiter chooses damage/price |
outcome accepted from client |
send intent/ID; derive and apply on server |
| arbitrary object can be deleted |
only typeof(Instance) checked |
validate class, ancestry, ownership, state, and allowlisted operation |
| server stalls on a player |
server invokes client RemoteFunction |
replace with asynchronous events |
| valid player triggers throttling |
per-frame reliable messages |
lower frequency, state replication, batching, or unreliable cosmetics |
| old packet reverses new effect |
unordered unreliable samples treated as commands |
make samples replaceable/versioned; use reliable event for transitions |
| remote breaks after respawn |
cached character/root |
resolve current character during handling and reject stale state |
| private data leaks |
FireAllClients used by default |
use FireClient and minimal payloads |
| distance check is bypassed |
client-owned object moved near target |
anchor/server-own critical object and validate full server context |
Resources
- Read
references/validation-and-testing.md for payload rules, Instance/finiteness checks,
replication design, and the required multi-client abuse matrix.
Related skills
roblox-luau — execution locations and basic RemoteEvent mechanics.
roblox-characters — respawn-safe character resolution.
roblox-physics — network ownership, ray/overlap validation, and physical consequences.
roblox-studio-workflow — Server & Clients testing and Output inspection.
Primary references
https://create.roblox.com/docs/scripting/events/remote
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
1---
2name: roblox-networking
3description: >
4 Design and harden Roblox client/server networking with RemoteEvent, RemoteFunction, and
5 UnreliableRemoteEvent; server authority, argument and Instance validation, rate limits,
6 proximity/ownership checks, targeted replication, streaming, lifecycle, prediction, and
7 reconciliation. Use for Roblox remotes, exploits, request spam, multiplayer replication,
8 network ownership, high-frequency cosmetic updates, or server/client desynchronization.
9---
10
11# Roblox networking
12
13Build explicit request and replication contracts in which the server decides authoritative game
14state and clients provide input or intent. Targets Roblox's rolling platform APIs. This skill goes
15deeper than the networking primer in `roblox-luau`.
16
17## When to use
18
19- Use to design, implement, debug, or secure cross-boundary Roblox communication.
20- Use when a remote trusts client values, an exploiter can target arbitrary Instances, messages
21 spam services, streamed objects are missing, or clients disagree with the server.
22
23**When not to use:** basic Luau/services belong to `roblox-luau`; persistent state belongs to
24`roblox-datastores`; physical ownership mechanics also compose with `roblox-physics`.
25
26## Workflow
27
281. **Inspect the existing protocol.** Find every remote and both endpoints; document direction,
29 sender, payload, frequency, authority, validation, and consumers. Reuse the canonical remote
30 folder—do not create a duplicate because discovery was skipped.
312. **Classify each message.** Client request, server fact, or ephemeral cosmetic sample. Choose
32 reliable event, unreliable event, or request/response from semantics—not convenience.
333. **Minimize the payload.** Send stable identifiers and intent. Do not send a price, damage,
34 ownership result, arbitrary path, or computed outcome the server can derive.
354. **Validate in layers.** Check type/shape/finiteness, allowlisted value, Instance class and
36 ancestry, player permissions/state, distance/line of sight where relevant, server cooldown,
37 and rate budget before doing expensive work.
385. **Apply on the server.** The server resolves targets and mutates health, inventory, currency,
39 cooldowns, and progression. Client-side checks improve UX but grant no trust.
406. **Replicate narrowly.** Use `FireClient` for private or local facts; broadcast only shared facts.
41 Avoid sending replicated properties again unless the client needs a distinct presentation event.
427. **Handle time and lifecycle.** Requests may arrive after death, respawn, streaming changes, or
43 disconnect. Resolve the current character/state during handling and clean per-player limiter data.
448. **Verify with Server & Clients.** Exercise normal, malformed, spam, out-of-range, stale
45 character, rapid respawn, leaving, simultaneous players, targeted, and broadcast cases. Inspect
46 server and each client Output separately.
47
48## Choose the transport
49
50| Primitive | Use | Do not use |
51|---|---|---|
52| `RemoteEvent` | ordered, reliable one-way requests/facts | continuous samples where newer replaces older |
53| `UnreliableRemoteEvent` | ephemeral cosmetic/continuous state tolerant of loss and reordering | purchases, damage decisions, inventory, one-shot state transitions |
54| `RemoteFunction` | bounded client-to-server query that truly needs an immediate reply | server-to-client invocation; long/uncertain work; ordinary commands |
55
56Never invoke a client synchronously from the server. A client may disconnect, error, or never
57return. Prefer server `RemoteEvent:FireClient()` and a separate response event when needed.
58
59## Pattern: validate before resolving gameplay
60
61```lua
62-- ServerScriptService/CombatRequests.server.luau
63local Players = game:GetService("Players")
64local ReplicatedStorage = game:GetService("ReplicatedStorage")
65local Workspace = game:GetService("Workspace")
66
67local attack = ReplicatedStorage.Remotes.Attack
68local lastRequest: {[Player]: number} = {}
69local RANGE = 12
70local COOLDOWN = 0.25
71
72attack.OnServerEvent:Connect(function(player: Player, target: unknown)
73 local now = Workspace:GetServerTimeNow()
74 if now - (lastRequest[player] or -math.huge) < COOLDOWN then return end
75 lastRequest[player] = now
76
77 if typeof(target) ~= "Instance" or not target:IsA("Model") then return end
78 if not target:IsDescendantOf(Workspace.Characters) then return end
79 local targetHumanoid = target:FindFirstChildOfClass("Humanoid")
80 local targetRoot = target:FindFirstChild("HumanoidRootPart")
81 local character = player.Character
82 local root = character and character:FindFirstChild("HumanoidRootPart")
83 local humanoid = character and character:FindFirstChildOfClass("Humanoid")
84 if not targetHumanoid or not targetRoot or not root or not humanoid then return end
85 if humanoid.Health <= 0 or targetHumanoid.Health <= 0 then return end
86 if (root.Position - targetRoot.Position).Magnitude > RANGE then return end
87 if not serverCombatStateAllowsAttack(player, now) then return end
88
89 targetHumanoid:TakeDamage(serverDamageFor(player))
90end)
91
92Players.PlayerRemoving:Connect(function(player)
93 lastRequest[player] = nil
94end)
95```
96
97This is still only a compact example: a real melee system may require server-known attack windows,
98line-of-sight/shape checks, team rules, and lag policy. Do not treat one distance check as security.
99
100## Pattern: token bucket at the boundary
101
102```lua
103type Bucket = {tokens: number, updatedAt: number}
104local buckets: {[Player]: Bucket} = {}
105local CAPACITY, REFILL_PER_SECOND = 6, 3
106
107local function consume(player: Player, cost: number): boolean
108 local now = os.clock()
109 local bucket = buckets[player] or {tokens = CAPACITY, updatedAt = now}
110 bucket.tokens = math.min(CAPACITY,
111 bucket.tokens + (now - bucket.updatedAt) * REFILL_PER_SECOND)
112 bucket.updatedAt = now
113 if bucket.tokens < cost then buckets[player] = bucket; return false end
114 bucket.tokens -= cost
115 buckets[player] = bucket
116 return true
117end
118```
119
120Assign cost by server impact. Reject cheaply before datastore calls, cloning, raycasts, or broad
121replication. Log aggregate abuse signals, not one warning per rejected packet.
122
123## Replication, streaming, and prediction
124
125- Replicated Instances/properties are already a state channel. Use remotes for intent, private
126 state, or presentation cues, not an unconditional parallel copy of the DataModel.
127- With instance streaming, a valid server Instance may not exist on a client. Send a stable ID and
128 tolerate absence; do not wait forever for optional streamed content.
129- High-rate cosmetic data may use `UnreliableRemoteEvent`; make each sample self-contained because
130 delivery and order are not guaranteed. Payloads over **1000 bytes are dropped** (Studio Output
131 reports the overage). `RemoteEvent` and `UnreliableRemoteEvent` also share a throttle of roughly
132 **500 calls/second per client**, counted across all remotes of that type — which is what a
133 legitimate player hits before any attacker does.
134- Predict only latency-sensitive reversible presentation. Include a client sequence/command ID;
135 the server returns authoritative state and acknowledgement; the client corrects smoothly. Never
136 let prediction award damage, currency, inventory, or progression.
137- Network ownership improves responsiveness but lets that client influence physical simulation.
138 Validate gameplay consequences on the server; ownership is not authorization.
139
140## Common failures
141
142| Symptom | Likely cause | Remedy |
143|---|---|---|
144| exploiter chooses damage/price | outcome accepted from client | send intent/ID; derive and apply on server |
145| arbitrary object can be deleted | only `typeof(Instance)` checked | validate class, ancestry, ownership, state, and allowlisted operation |
146| server stalls on a player | server invokes client `RemoteFunction` | replace with asynchronous events |
147| valid player triggers throttling | per-frame reliable messages | lower frequency, state replication, batching, or unreliable cosmetics |
148| old packet reverses new effect | unordered unreliable samples treated as commands | make samples replaceable/versioned; use reliable event for transitions |
149| remote breaks after respawn | cached character/root | resolve current character during handling and reject stale state |
150| private data leaks | `FireAllClients` used by default | use `FireClient` and minimal payloads |
151| distance check is bypassed | client-owned object moved near target | anchor/server-own critical object and validate full server context |
152
153## Resources
154
155- Read `references/validation-and-testing.md` for payload rules, Instance/finiteness checks,
156 replication design, and the required multi-client abuse matrix.
157
158## Related skills
159
160- `roblox-luau` — execution locations and basic RemoteEvent mechanics.
161- `roblox-characters` — respawn-safe character resolution.
162- `roblox-physics` — network ownership, ray/overlap validation, and physical consequences.
163- `roblox-studio-workflow` — Server & Clients testing and Output inspection.
164
165## Primary references
166
167- `https://create.roblox.com/docs/scripting/events/remote`
168- `https://create.roblox.com/docs/scripting/security/client-server-boundary`
169- `https://create.roblox.com/docs/physics/network-ownership`
170- `https://create.roblox.com/docs/studio/testing-modes`