Lesson 6 of 9 · 29m
Roblox and Luau: Server Authority in a Scripting World
Design Roblox systems where clients present intent, server Scripts validate and mutate authoritative state, and RemoteEvents never become trust boundaries.
Roblox teaches a lesson every multiplayer engine eventually teaches: the client is a renderer and input device wearing a very convincing costume. It is not authoritative. Exploiters can inspect client code, modify memory, fire remotes with arbitrary arguments, and automate input. If your Roblox game security depends on hiding a LocalScript, you do not have security; you have inconvenience.
Understand the Luau split
Roblox uses Luau, a Lua-derived language with gradual typing and platform-specific APIs. Script runs on the server, LocalScript runs on the client, and ModuleScript shares code when required. Replication rules decide what each side sees. Client prediction is fine for movement feel, animation, and cosmetic feedback; it is not proof that damage, currency, inventory, or access control should be accepted.
The mental model is simple:
client input, prediction, presentation, local responsiveness
remote untrusted intent message
server validation, authorization, authoritative mutation, replicationTreat RemoteEvent arguments as hostile input
A client can fire a remote correctly, but it can also send wrong types, enormous strings, negative quantities, or another player's identifier. The server validates everything after the trusted player argument:
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PurchaseRemote = ReplicatedStorage:WaitForChild("PurchaseItem")
local cooldowns = {}
Players.PlayerRemoving:Connect(function(player)
cooldowns[player.UserId] = nil
end)
PurchaseRemote.OnServerEvent:Connect(function(player, itemId)
if typeof(itemId) ~= "string" or #itemId > 64 then return end
local now = os.clock()
if cooldowns[player.UserId] and now - cooldowns[player.UserId] < 0.5 then
return
end
cooldowns[player.UserId] = now
local item = ItemCatalog[itemId]
if item and item.enabled then InventoryService.purchase(player, item) end
end)Roblox supplies player itself. Everything after it is attacker-controlled input.
Validate consequences, not just syntax
Type checks are only the first layer. The server must ask whether the action is currently legal: Does the player own the required item? Are they close enough to the vendor? Is the round active? Is the target alive? Is the quantity positive? Is the price correct? Is there a cooldown? Client-side checks are user experience; server-side checks are truth.
Remote design is API design
Do not create one generic remote named DoAction accepting a command table. That is an invitation to build an untyped RPC maze. Use narrow remotes with explicit semantics: PurchaseItem, UseAbility, EquipCosmetic, ReportInput. Log abuse with player ID and remote name, and rate-limit expensive or security-sensitive events.
Client code still matters
Server authority does not mean client quality is irrelevant. LocalScripts should provide immediate feedback, avoid leaking hidden design details unnecessarily, clean up connections, and never store secrets. Anything in a client script is visible to determined users. Put validation and secrets on the server; put responsiveness and presentation on the client.
Field notes
FireServerdoes not authenticate business intent; it only carries a message from a particular player connection.- Never trust positions, hit reports, cooldown completion, or prices supplied by the client.
- Use server-side rate limits per player and per action, not only global limits.
- Client prediction may diverge; reconcile it against server state instead of treating disagreement as proof of cheating.
Was this lesson helpful?