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 not to use: basic Luau/services belong to roblox-luau; persistent state belongs to
roblox-datastores; physical ownership mechanics also compose with roblox-physics.
FireClient for private or local facts; broadcast only shared facts.
Avoid sending replicated properties again unless the client needs a distinct presentation event.| 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.
-- 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.
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.
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.| 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 |
references/validation-and-testing.md for payload rules, Instance/finiteness checks,
replication design, and the required multi-client abuse matrix.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.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