Guide · 8 min read · Updated November 2026
Roblox RemoteEvent security with AI: the checks every handler needs
Every exploiter can fire any RemoteEvent with any arguments, read every LocalScript and change any client-side value. That is not a worst case; it is the baseline, because the client is their computer. Good remote security is boring: a handful of checks on every server handler, applied without exception. This guide lists them, shows the prompt that gets an AI agent to apply them across your whole place, and explains how to read the result.
Layout first
- Remotes live in a Folder,
ReplicatedStorage.Remotes, named by intent:BuyItem,RequestUpgrade,Notify. One remote per action, not one remote with a string that says what to do. - Client to server:
FireServerandOnServerEvent. Server to client:FireClientandFireAllClients. Client asks for a value:OnServerInvoke, with the client call in a pcall. High-frequency cosmetics (aim, footsteps):UnreliableRemoteEvent. - Never
RemoteFunction:InvokeClient.
The checks, on every server handler
remote.OnServerEvent:Connect(function(player: Player, itemId: unknown)
if typeof(itemId) ~= "string" then return end
local item = Items[itemId]; if not item then return end -- whitelist; never trust prices from the client
if not RateLimit.Allow(player, "BuyItem", 5) then return end -- 5 per second per player
local data = PlayerData.Get(player); if not data then return end
if data.Coins < item.Price then Notify(player, "Not enough coins"); return end
Economy.AddCoins(player, -item.Price, "buy:" .. itemId)
data.Unlocks[itemId] = true
remote:FireClient(player, "ok", itemId)
end)
- Types.
typeofon every argument. For numbers:type(n) == "number",n == n(rejects NaN),n == math.floor(n)where an integer is expected, then clamp the range. - Whitelists. Item ids, upgrade ids, map names and ability names are looked up in server config. The price, damage or reward is read from that config, never from the argument.
- Distance. Anything positional (a pickup, a buy prompt, a hit) checks the distance from the player's character, and line of sight if it matters.
- Rate limits. One small module with a table of timestamps per player per remote. Extras are dropped, not punished.
- The sender is the first parameter. A player id in the arguments is ignored.
- Silent drops. Invalid input gets no reply. Kick only for the impossible, never for lag.
- Data readiness. Handlers call
PlayerData.GetorWaitForand return if the data is not loaded, so a remote fired during join cannot act on an empty table.
Where secrets live
Everything in ReplicatedStorage and every LocalScript is readable by an exploiter. Drop tables, egg odds used for the roll, admin lists, redeem codes and product grant logic belong in ServerStorage or ServerScriptService. Shared config in ReplicatedStorage should hold what the UI needs to display (names, prices, icons) and nothing that would help someone cheat. Also remove any require(assetId) loaders and loadstring from free models; those are backdoors.
Weapons, movement and income
- Hits: the client sends where it aimed; the server raycasts from the character and applies damage, with fire rate and ammo from server data.
- Movement: once a second the server compares the root position with the last sample; more than
WalkSpeed x 1.5 + 10studs without a server teleport flag moves the player back and adds a strike; five strikes in a minute kicks. Never auto-ban. - Income:
AddCoinsclamps per-minute earnings to about 10x the best legitimate rate for the player's upgrades and warns on overflow, so a bug cannot print money either.
The common bugs
- A handler declared in a LocalScript:
OnServerEventonly works in a server Script. - The remote referenced before it exists on the client: use
WaitForChild("Remotes"):WaitForChild("BuyItem"). - Forgetting
playeras the first parameter, so the first argument is treated as the player. - An
OnServerInvokethat yields on a DataStore for every call, letting a client spam it into throttling. Cache, and rate-limit.
The security-pass prompt
Review every RemoteEvent and RemoteFunction handler on the server in my place. For each:
validate argument types (reject NaN and non-integers where integers are expected), whitelist
ids against the config tables, clamp ranges, check distance from the player's character for
anything positional, add a per-player rate limit through one RateLimit module, never trust a
price, amount or player id from the client, and drop invalid input silently. Replace any
RemoteFunction InvokeClient. Fix what you find and summarise each change with the script
path and line.
This is the anti-exploit prompt; the movement and income checks are the speed and income sanity prompt. Forge applies its remotes playbook, playtests, and returns a list of changes by path and line. The same instructions work with Claude Code or Cursor on Studio's MCP server; you run the playtest.
Reading the result
- Every
OnServerEventandOnServerInvokein the summary has a type check as its first lines. - No handler reads a price, amount or reward from its arguments.
InvokeClientappears nowhere in the place.- The RateLimit module exists once and is required by every handler.
- Legitimate play still works: buy, click, hit, teleport, in a playtest.
What it costs
A security pass is a system-sized job, 100 to 500 credits ($1 to $5) on Sonnet 5.5 depending on how many handlers the place has. Ranges and packs are on the pricing page.
Questions
What is the single most important rule?
The first parameter of OnServerEvent is always the real sender. Never trust a player, a price, an amount or a target passed as an argument. The server decides; the client requests.
Should invalid input kick or ban?
Neither, by default. Drop it silently; an error reply is information for the exploiter. Kick only for input that is impossible rather than merely wrong, and never auto-ban on movement checks, because lag looks like speed.
Why is RemoteFunction:InvokeClient banned?
The server waits for the client to answer, and a client can simply never answer, hanging that server thread forever. Use FireClient for one-way messages and OnServerInvoke for the client asking the server.
Does a security pass break legitimate play?
It can, if a range or rate is set too tight. Forge playtests after the pass and lists every change by script and line; if a check is too strict, name it and it loosens that one.
Related guides
- Fix my Roblox script with AI: errors that look like security problems and the reverse.
- Roblox DataStore script with session locking: the data readiness check depends on it.
- Game pass and developer product scripts with AI: the one remote-adjacent path that must be idempotent.
- Trading system prompt: the hardest remote surface, done with two-step confirmation.