--- name: roblox-networking description: "Use when building, fixing or reviewing client-server traffic: remotes, replication, argument validation, hit checks, rate limits." when_to_use: "Also when events are dropped, late or out of order, a remote arrives nil, the server can't see a client-made part, hits don't register on moving or ragdolled targets, a reward is claimed twice, payload too big, throttled, or a remote handler needs a security review." last_reviewed: 2026-11-29 sources: - https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/scripting/events/remote.md - https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/reference/engine/classes/RemoteEvent.yaml - https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/reference/engine/classes/UnreliableRemoteEvent.yaml - https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/reference/engine/classes/RemoteFunction.yaml - https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/scripting/security/client-server-boundary.md - https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/scripting/security/access-control.md - https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/scripting/security/network-ownership.md - https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/scripting/attributes.md - https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/workspace/streaming/techniques.md - https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/projects/server-authority/index.md - https://raw.githubusercontent.com/Roblox/creator-docs/main/content/en-us/reference/engine/classes/Workspace.yaml - original --- # Roblox Networking ## When to Load How data moves between client and server: remotes, replication, argument validation, hit and movement checks, prediction. Economy, purchases, admin and audits: `roblox-security`; ownership and Server Authority physics: `roblox-physics` §3; bandwidth measurement: `roblox-performance`. "Field case" = measured in one of the owner's projects; tune on your game. ## Traps and review checklist (symptom -> cause -> fix) - **Reward or claim repeats** -> a remote argument can be any type and format; a table keyed by whatever the client sent gives `2`, `"2"` and `"02"` separate entries. `typeof` check, whole-number check, look the value up in the server's own list and key by the server's id; compute eligibility from server state; mark it claimed only after the grant succeeds, or make claim + grant one idempotent write (`roblox-data` §4). - **Table arrives mangled** -> mixed numeric + string keys break; non-string keys (Instance, userdata, function) become strings; a `nil` in any index truncates; metatables are stripped; functions arrive `nil`; tables are copies both ways. Send flat arrays or string-keyed dictionaries; validate every field, cap lengths and key counts. - **Server sends an Instance, client gets `nil`** -> the receiver must already have it: not yet replicated, streamed out, or never sent. An instance created inside a `RemoteFunction` may not exist on the client when the call returns. Send an id, resolve it on arrival, handle late or absent. A path string has the same problem and authorizes nothing. - **Client state change raced its remote** -> RemoteEvents on one connection are ordered (even across instances), but not relative to property and attribute replication, `RemoteFunction`s or `UnreliableRemoteEvent`s. Put related data on one channel or add a sequence number. Order is by handler **start**: a yielding handler lets the next message start first. - **Unreliable messages vanish** -> dropped (never resent) when > 1000 bytes, when the client exceeds the throttle, when no listener is connected yet, or on congestion; they arrive out of order. Studio Output logs how many bytes over. Use only for replaceable data, with a sequence number; never for currency, inventory or damage. - **Remote spam makes actions arrive late, not fail** -> a `RemoteEvent` over the throttle (§Limits) is delayed and kept in order, not dropped. Rate-limit in the handler so the server refuses early; reply to refusals. - **Server thread hangs or errors on a client call** -> `InvokeClient` rethrows the client's error, throws if the client leaves, and yields forever if it never returns. Use a `RemoteEvent`. `InvokeServer` allows one call in flight per thread; across threads, responses can return out of order. - **Every packet in a batch dropped, nil-index error inside a buffer library** -> a u8 string length wrapped past 255 bytes (401 became 145, field case). Use the long-string type for JSON and user text; assert sizes on the sender. - **First-person client deleted its own character's parts on the server** -> changes a client makes to its own character can replicate, and so do animation tracks it plays there. Hide with `LocalTransparencyModifier`; never remove parts. - **Timed reward exploited** -> `workspace:GetServerTimeNow()` is a smoothed shared clock (within 0.6% of local rate), and the docs call it not secure for timed rewards. Track durations server-side; a client timestamp is context, never proof: bound its age and match it to a server-known swing or shot id. - **Server Authority place: input sent by remote** -> simulation input goes through `InputAction` and `RunService:BindToSimulation()` (needs `Workspace.UseFixedSimulation`); remotes still carry discrete requests. Replicated attributes must be among an instance's first 64, name ≤ 50 chars, string value ≤ 50 chars. ## Limits | Item | Value | |---|---| | Client -> server rate | about 500 requests/s per client, shared by all remotes of the same type (RemoteEvent pool, Unreliable pool) | | `UnreliableRemoteEvent` payload | 1000 bytes, larger is dropped (encoding and compression make pre-fire size hard to predict: test-fire) | | No listener connected | `RemoteEvent`/`RemoteFunction`: queued until one connects; queue capped by count and memory, then `Remote event invocation discarded`. Unreliable: discarded at once | | Server -> client | no documented rate cap; cost is bytes × recipients (`FireAllClients` multiplies by player count): measure it (`roblox-performance`) | | Delivery scope | guarantees cover one connection in one direction; undelivered messages to a leaving client are lost | ## 1. Hit validation tolerances Docs (client-server-boundary): check the shot origin is near the shooter's server position with latency slack, the hit point is near the claimed part's server position, and only **static** geometry blocks line of sight (dynamic blockers have moved). Also server-side ammo, fire rate, team, alive, and blocking states. One working set (field case, tune your own): | Check | Tolerance | |---|---| | Claimed eye vs head | 6 studs + lag allowance | | Hit point vs target | 4 studs + target speed × 0.35 s, allowance capped at 60 studs | | Range / cone | range + 3 studs; cone + 5° (25° melee) | | Line of sight | colliding parts only; skip players and the target's body | | Fire rate | token bucket at 1.15× weapon rate, burst 3 | A ragdoll fix in another field case allowed up to 9 studs on non-standing targets. A failed tolerance check is a suspicion signal, not proof: count it, don't punish one packet. On characters that are combat targets, set accessories `CanQuery = false` so hats don't absorb headshots. ## 2. Client-triggered instances (official) Validate their server events like remotes: enabled state, player alive and in range, server cooldown. - `ProximityPrompt`: fires even with `Enabled = false` on the server; `Enabled`, `MaxActivationDistance`, `RequiresLineOfSight` and `HoldDuration` can be changed on the client. Only `Triggered` gets a server distance check; hold and `TriggerEnded` events have none. - `ClickDetector`: no server checks at all; fires at any distance, disabled, or not on anything clickable. - `DragDetector`: drag events check only `Enabled` and `PermissionPolicy`; clamp final positions server-side. ## 3. Prediction and timers (field cases) - A timer on both sides drifts by the message delay: accept within about 0.1 s of the end (held to 80 ms jitter) and test from the timer's last frame. - A melee server cooldown longer than the client's full swing (wind-up to recovery, miss path too) silently eats every other swing. - Ack every predicted command, accepted or refused, with the authoritative state on refusal; an ack for N means older unacked commands were dropped. Wrap-aware compare for u16 sequence numbers. - Predict cosmetics, not consequences: the shooter's own effect plays locally keyed by sequence (server-only effects took 190-290 ms even point blank); destruction, currency and score wait for the server.