Lesson 3 of 4
Remotes: events, functions, unreliable, buffers
Learn Roblox remotes. RemoteEvent, RemoteFunction and UnreliableRemoteEvent, who creates them, what the server can trust, buffers for bandwidth, rate limiting, and what networking libraries like ByteNet, Zap and Warp add, using Beacon Yard's five remotes.
By the end you can
- Choose between RemoteEvent, RemoteFunction and UnreliableRemoteEvent for a message, and say what each promises
- Read a handler and say which argument the engine supplies and which ones the client can forge
- Pack a small payload into a buffer and compare its size with a plain table
- Name the engine's remote rate limit and write a per-player limit of your own
Before this: Boot order: what runs first, Types: strict mode, the new type solver, generics
1Five names that carry the whole game
Everything one side of Beacon Yard says to the other goes through five objects in ReplicatedStorage.Remotes: RoundState, Feedback, ShopOpen, ShopBuy and Swing. The server creates them, one list in one file. A client that wants the shop to sell it a Speed upgrade does exactly one thing: fire ShopBuy with the word "Speed".
local REMOTE_NAMES: { string } = { "RoundState", "Feedback", "ShopOpen", "ShopBuy", "Swing" }

Select a numbered pin, or a row below, to read what it marks.
The server's view of ReplicatedStorage.Remotes during Play. Five RemoteEvents, all created by Remotes.init.
How many RemoteEvents does Beacon Yard's server create at m06?
Answer
5 remotes. RoundState, Feedback, ShopOpen, ShopBuy and Swing: five. The server owns the list, so a late-joining client and the server always agree on what exists.
Open this step in lesson mode · Link to this step · This confused me
2RemoteEvent: a note to the front desk
A RemoteEventRemoteEventAn object that sends a one-way message between a client and the server.Think of it as a note to the front-desk clerk. carries one message, one way, and the sender does not wait. A client fires it with remote:FireServer(...). The server listens with remote.OnServerEvent:Connect(function(player, ...) end). To go the other way, the server calls FireClient(player, ...) for one player or FireAllClients(...) for everybody, and clients listen with OnClientEvent1.
| In the picture | In Roblox |
|---|---|
| Writing a note | FireServer from a LocalScript |
| The clerk reading it | OnServerEvent running on the server |
| The name on the envelope | The player argument the engine adds |
A RemoteEvent is a note handed to a clerk at the front desk. The clerk reads it later, and you do not stand there waiting for a reply.
Think of it as A note to the front-desk clerk
Look at who is who in the handler's parameters. The engine puts the sender first, and everything after it is whatever the client wrote on the note.
Remotes.get("ShopBuy").OnServerEvent:Connect(function(player: Player, item: unknown)
ShopService.purchase(player, item)
end)
The cell below fakes the desk with a Signal, so you can see the stamping rule. The player is added by the code that delivers the note, never by the sender.
local ShopBuy = Signal.new()
-- The server's handler: the first argument is the sender.
ShopBuy:Connect(function(player, item)
print("ShopBuy from " .. player .. " asked for " .. tostring(item))
end)
-- What the engine does when a client fires: it adds the real sender.
local function fireServer(realPlayer, ...)
ShopBuy:Fire(realPlayer, ...)
end
fireServer("Ava", "Speed")
-- A forged "name" in the payload cannot replace the sender.
fireServer("Ava", "Shield", "I am really Ben")
ShopBuy from Ava asked for Speed
ShopBuy from Ava asked for ShieldA modified client fires ShopBuy with the arguments ("Speed", "I am Ben"). In ShopService's handler function(player, item), who is player?
Answer
The client who really fired; the engine fills that slot. OnServerEvent's first parameter is always the real sender, supplied by the engine. Everything after it, including a claim to be someone else, is text the client wrote.
Open this step in lesson mode · Link to this step · This confused me
3Who fires what
Each of the five remotes has a direction. The server fires three of them to clients and listens to two.
Match each Beacon Yard remote to what travels on it.
Answer
RoundState: Server to every client: the phase and when it ends; Feedback: Server to one player, or to everyone for round events: a kind and some text, such as coin and +5; ShopOpen: Server to the player who used the prompt: no arguments; ShopBuy: Client to server: the item the player wants; Swing: Client to server: an origin and a direction. RoundState, Feedback and ShopOpen are announcements from the server. ShopBuy and Swing are requests from the client. Neither request carries a price, a coin count or a damage number.
Notice what is missing from the two requests: a price, a damage number, a user id. They are not fields the server wants from a client, so they are not fields at all.
swing:FireServer(origin, direction)
CombatClient fires Swing with an origin and a direction. How much damage does a hit do, and where does that number come from?
Answer
34, from Config.WRENCH_DAMAGE on the server; the client never sends it. Swing carries only an origin and a direction. After the server's checks and a ray hit, CombatService applies Config.WRENCH_DAMAGE, 34, from its own copy of the number.
Open this step in lesson mode · Link to this step · This confused me
4RemoteFunction: a phone call on hold
A RemoteFunction is a call that waits for an answer. remoteFunction:InvokeServer(...) pauses the calling script until the server's OnServerInvoke returns a value. It is the right shape for "give me a number and wait for it", such as a client asking for its own inventory.
| In the picture | In Roblox |
|---|---|
| Dialling and waiting on the line | InvokeServer yielding until the server returns |
| The person answering | The OnServerInvoke callback |
| The answer you hear | The value the callback returns |
The danger is on the other side. If the server calls InvokeClient, it yields until the player's device answers. If that client disconnects, InvokeClient throws an error. Worse, if a hung or modified client never returns a value, the server yields forever1. In practice the server rarely invokes a client: clients usually know nothing the server does not.
Beacon Yard has no RemoteFunction at all. The result of a purchase comes back as a later Feedback event, so the shop never sits on hold.
Both sidesRemember: A RemoteFunction is a phone call on hold.
ShopService decides whether a purchase worked. Why does it answer with a Feedback event instead of making ShopBuy a RemoteFunction that returns true or false?
Answer
An event never leaves a script waiting, and the server never depends on a client to keep a call alive. With an event, the client fires and carries on, and the server answers whenever it is ready. Nothing blocks. A function would hold the client's script until the server replied.
A real phone call eventually times out or drops cleanly when the other side hangs up. Calling a client from the server does not protect you from a client that keeps the line open forever.
Where does it break?“A phone call on hold” is a good picture of a remotefunction. Where does it stop being true?
It breaks here. If the server calls a player, the player controls the line: a disconnected client throws an error, and a hung or modified client that never returns leaves the server's script yielding forever.
The true model. InvokeServer and InvokeClient yield until a response arrives. A server that invokes a client has no way to force an answer, so servers should avoid depending on clients and should answer with events instead.
A server script calls remoteFunction:InvokeClient(player) on a modified client whose OnClientInvoke handler runs task.wait(math.huge) and never returns. What happens to the server thread?
Answer
It yields forever, waiting for a reply that never arrives. A disconnect throws an error you can catch with pcall, but a connected client that refuses to return leaves InvokeClient yielding forever. Avoid invoking clients from the server.
Open this step in lesson mode · Link to this step · This confused me
5UnreliableRemoteEvent: shouting across a noisy field
An UnreliableRemoteEvent is a RemoteEvent that drops two promises. Messages can be lost, and they can arrive out of order. In return it costs less to send, because the engine does not retry or queue. It suits things that are replaced a moment later: a stream of positions, a sparkle, a footstep sound. It must never carry anything that has to arrive once, such as a purchase2.
| In the picture | In Roblox |
|---|---|
| Shouting a position | FireServer or FireClient on an UnreliableRemoteEvent |
| Some words get lost in the wind | Dropped, unordered messages |
| Shouting the latest again a moment later | Streaming positions that replace each other |
There is a hard cap: a payload over 1000 bytes is dropped. The cell below sends a stream of positions and loses some, as the network might. Look at what a receiver sees.
Both sidesRemember: An UnreliableRemoteEvent is shouting across a noisy field.
local stream = Signal.new()
local latest = nil
stream:Connect(function(x)
latest = x
print("got x=" .. x)
end)
for x = 0, 4 do
if x ~= 2 then -- the network lost this one
stream:Fire(x)
end
end
print("latest x=" .. latest)
got x=0
got x=1
got x=3
got x=4
latest x=4Where does it break?“Shouting across a noisy field” is a good picture of an unreliableremoteevent. Where does it stop being true?
It breaks here. Shouting is fine for a position that is replaced a moment later, never for anything that must arrive once; and a payload over 1000 bytes is dropped outright.
The true model. UnreliableRemoteEvent skips resends and ordering to save latency and traffic. It is for continuously changing or short-lived data only; anything that changes game state exactly once belongs on a RemoteEvent.
Retiring the analogy
You no longer need “shouting across a noisy field”. UnreliableRemoteEvent skips resends and ordering to save latency and traffic. It is for continuously changing or short-lived data only; anything that changes game state exactly once belongs on a RemoteEvent.
Which of these could safely travel on an UnreliableRemoteEvent in Beacon Yard?
Answer
The drone's position, sent many times a second; A decorative spark where the wrench hit. The next drone position replaces a lost one, and a missing spark is invisible. A purchase and a phase change must arrive exactly once, so they stay on ordinary RemoteEvents.
Open this step in lesson mode · Link to this step · This confused me
6Buffers: fewer bytes for the same message
Roblox compresses what you send, but a table of named fields still carries names, types and structure. A bufferBufferA fixed block of bytes that you read and write yourself, used to send small, exact payloads.Think of it as a strip of numbered boxes where you decide what goes in each one. is a fixed block of bytes you fill yourself, so you decide exactly how many bytes each value takes3. Writing a number as one byte (writeu8), two (writeu16) or four (writef32) is how libraries cut bandwidth. The cost is that you now write the layout twice, once to pack and once to unpack, and both sides must agree.
Here is a drone update packed into 15 bytes: a one-byte id, three four-byte floats for the position, and a two-byte heading. At m06-drone-wrench, the server updates the drone transform with PivotTo on Heartbeat while the drone is active and unstunned. Sending the 15-byte buffer at 10 Hz gives 150 bytes per second of raw payload per recipient, or 3,000 bytes per second for 20 recipients, before Roblox encodes and transports it. Measure actual traffic with Network Stats in Module 13, The network budget.
local function pack(id, x, y, z, headingDegrees)
local b = buffer.create(15)
buffer.writeu8(b, 0, id)
buffer.writef32(b, 1, x)
buffer.writef32(b, 5, y)
buffer.writef32(b, 9, z)
buffer.writeu16(b, 13, headingDegrees)
return b
end
local function unpack3(b)
return buffer.readu8(b, 0), buffer.readf32(b, 1), buffer.readf32(b, 5), buffer.readf32(b, 9), buffer.readu16(b, 13)
end
local packet = pack(1, 22.5, 4, -10.25, 90)
local bytes = buffer.len(packet)
local hz, players = 10, 20
local perPlayer = bytes * hz
local totalPayloadKiB = (perPlayer * players) / 1024
print(bytes)
print(unpack3(packet))
print(string.format("10 Hz raw payload: %d B/s per player, %.2f KiB/s for %d players", perPlayer, totalPayloadKiB, players))
15
1 22.5 4 -10.25 90
10 Hz raw payload: 150 B/s per player, 2.93 KiB/s for 20 playersA packet holds a one-byte id, three four-byte floats and a two-byte heading. How many bytes is the buffer?
Answer
15 bytes. 1 + 12 + 2 = 15 bytes. Ten of these a second is 150 bytes a second per drone, a number you can reason about because you chose every byte.
Open this step in lesson mode · Link to this step · This confused me
7Rate limits: the engine's and yours
The engine already throttles each client: about 500 FireServer calls per second, shared by all RemoteEvents of the same type. What happens above that depends on the type. A RemoteEvent's excess calls are processed later, in order, not dropped. An UnreliableRemoteEvent's excess calls are dropped1. That protects the engine, not your game. A player can still fire ShopBuy 400 times a second, and every one of them is a valid request.
Your game's own rule goes on top. Beacon Yard's Swing handler remembers the server time of each player's last swing and refuses another within 0.4 seconds.
local now = workspace:GetServerTimeNow()
local previousSwing = lastSwing[player]
if previousSwing ~= nil and now - previousSwing < SWING_GAP then
return "rejected"
end
lastSwing[player] = now
The cell below is the same rule with a virtual clock. Notice that a refused attempt does not move the clock, so the window opens exactly once per allowed call.
local last = {}
local function allow(player, gap)
local now = time()
local previous = last[player]
if previous ~= nil and now - previous < gap then
return false
end
last[player] = now
return true
end
print(allow("Ava", 0.4))
print(allow("Ava", 0.4))
task.wait(0.2)
print(allow("Ava", 0.4))
task.wait(0.25)
print(allow("Ava", 0.4))
print(allow("Ava", 0.4))
true
false
false
true
falseAt m06, Swing has a 0.4 second gap and ShopBuy has none. Which statement is true?
Answer
A client can fire ShopBuy as fast as the engine allows; every request is still checked against the profile, but the handler adds no per-player cooldown. Only CombatService has a gap. ShopBuy still checks the item and the balance on every request, so nothing is stolen, but a flood goes through. The rate limit is the level 3 challenge in the security lesson, which adds the missing gap.
Open this step in lesson mode · Link to this step · This confused me
8Where the front desk breaks
Both sidesRemember: A RemoteEvent is a note to the front-desk clerk.
A clerk who reads a note with a name on it might believe the name. The engine does something stricter for you.
Where does it break?“A note to the front-desk clerk” is a good picture of a remoteevent. Where does it stop being true?
It breaks here. The engine stamps the sender for you, but every other word on the note can be a lie.
The true model. A RemoteEvent carries a one-way message between a client and the server. The server always learns which player sent it; every other argument is untrusted input that the server must check.
ShopService receives ShopBuy(player, item). Which of these can the server trust without checking?
Answer
player, the sender. Only the sender is stamped by the engine. The item can be any value, a balance in the packet is a claim, and whether a buy is allowed depends on the server's own profile. ShopService compares the item and reads the profile.
Open this step in lesson mode · Link to this step · This confused me
9Build it: add a Ping, then meet the libraries
You can do everything in this lesson with the engine's own remotes, and Beacon Yard does. Large games often put a library over them. Here is what exists and when professionals reach for it.
Remotes, or a networking library?
| Option | What it is | When pros pick it | Trade-offs |
|---|---|---|---|
| Plain RemoteEvents | The engine's own objects. Beacon Yard uses these. | Most games, especially small and mid-size ones, and everything you are still learning. | You write validation by hand, and tables are sent with names and structure, which costs bandwidth. |
| Zap | You describe events in a small schema file; a compiler generates typed Luau that packs data into buffers and validates what it receives. | Games with many events or heavy traffic, and teams that want schema-checked, small packets. | A build step and a schema language. Its README calls it an early pre-release, so check the changelog before betting a game on it. |
| ByteNet | A library that serializes your data into buffers using type definitions you write in Luau. | Teams that want buffer-sized packets without a separate compiler. | Another dependency, and your data must fit its supported types. |
| Warp | A networking library that serializes dynamically, with optional schemas. | Teams that want less bandwidth than plain remotes with little setup. | Dynamic packing gives up some of what a fixed schema saves. |
| Red | An older library that packs events through a single remote. | You will meet it in existing games. | Its repository is archived, so do not start a new project on it. |
Build along
src/server/Remotes.luausrc/server/init.server.luau
Check out
m06-drone-wrench, runrojo serve, press Play, switch to the Server view and expandReplicatedStorage.Remotes.You should see Explorer, in the Server view during Play, lists five RemoteEvents under ReplicatedStorage.Remotes.
Switch to the Client view. In the command bar run
game.ReplicatedStorage.Remotes.ShopBuy:FireServer("Nope").You should see An Unknown item toast appears at the bottom of the HUD, and your coin count does not change.
With at least 25 coins and no Speed upgrade yet, run
game.ReplicatedStorage.Remotes.ShopBuy:FireServer("Speed", 0, "free"). Watch the coin count fall by 25, not by 0.You should see A Speed purchase works when you have 25 coins, with no price in the message.
Open this step in lesson mode · Link to this step · This confused me
10Challenges
Level 1, Apprentice
Challenge
Name the five remotes and their directions before looking at the file.
- Start from
- The game at milestone m06 (download)
Done means
- You list the five names from memory and mark ShopBuy and Swing as client to server
- You check your list against REMOTE_NAMES
Hints
- RoundState, Feedback and ShopOpen leave the server.
- Open src/server/Remotes.luau and compare.
-- A swing is valid when origin and direction are both Vector3 values,
-- every part is a finite number, and the direction is longer than 0.001.
local function validSwing(origin, direction)
return true
end
Level 3, Professional
Challenge
Add a Ping remote end to end. The solution is challenges/solutions/remotes.md in the game repo.
- Start from
- The game at milestone m06 (download)
- Grade it
- To grade work from an earlier milestone, apply your challenge changes to a checkout based on
m14-ship, which includes the Course Runner. In Studio, press Play, then runrequire(game.ReplicatedStorage.GameTests.RunChallenge)("remotes")in the client command bar. Copy the pass code from Output.
Done means
- REMOTE_NAMES gains a sixth name, Ping, and the server (not a client) creates it
- After Remotes.init() in init.server.luau, the server answers Ping with FireClient and the string pong, ignoring the client's argument
- The Course Runner prints TEST PASS remotes_ping and a pass code
Hints
- FireServer only works on the client, so the test runs from the client command bar.
- If you echo the client's argument, the test fails: it sends nope and wants the server's own word.
- Remotes.init creates the instance; the OnServerEvent connection has to be on that instance.
Open this step in lesson mode · Link to this step · This confused me
11Recap
Retiring the analogy
You no longer need “a note to the front-desk clerk”. A RemoteEvent carries a one-way message between a client and the server. The server always learns which player sent it; every other argument is untrusted input that the server must check.
Retiring the analogy
You no longer need “a phone call on hold”. InvokeServer and InvokeClient yield until a response arrives. A server that invokes a client has no way to force an answer, so servers should avoid depending on clients and should answer with events instead.
Recap
- A RemoteEvent is a one-way message; the engine supplies the sender as the first argument on the server, and everything after it is untrusted. RemoteFunction waits for a reply and can hang a server if it calls a client, so Beacon Yard uses events and answers with Feedback.
- UnreliableRemoteEvent may lose or reorder messages and caps a payload at 1000 bytes, so it carries only things that are replaced a moment later. Buffers let you choose each byte, at the cost of writing the layout twice.
- The engine allows about 500 client fires a second per remote type; a RemoteEvent delays the excess and an UnreliableRemoteEvent drops it. Your own rules, such as Swing's 0.4 second gap, go on top, and libraries like Zap, ByteNet and Warp are optimizations for heavy traffic.
A RemoteEvent is a note to the front-desk clerk, until the engine stamps the sender for you, but every other word on the note can be a lie.
A RemoteFunction is a phone call on hold, until if the server calls a player, the player controls the line: a disconnected client throws an error, and a hung or modified client that never returns leaves the server's script yielding forever.
An UnreliableRemoteEvent is shouting across a noisy field, until shouting is fine for a position that is replaced a moment later, never for anything that must arrive once; and a payload over 1000 bytes is dropped outright.
Queued for review
- A modified client fires ShopBuy with the arguments ("Speed", "I am Ben"). In ShopService's handler function(player, item), who is player?
- Match each Beacon Yard remote to what travels on it.
- Which of these could safely travel on an UnreliableRemoteEvent in Beacon Yard?
- A packet holds a one-byte id, three four-byte floats and a two-byte heading. How many bytes is the buffer?
- ShopService receives ShopBuy(player, item). Which of these can the server trust without checking?
Open this step in lesson mode · Link to this step · This confused me