Lesson 5 of 11
The network budget: measure, batch, pack
Put Beacon Yard's network traffic on a budget. Measure KB/s per player, turn the drone's per-frame PivotTo into a 10 Hz bit-packed UnreliableRemoteEvent stream with client interpolation, and compare hand-packed buffers with Blink and Zap.
By the end you can
- Measure what each system sends per player per second, and keep it in a budget table
- Replace the drone's per-frame PivotTo with a 10 Hz bit-packed snapshot on an UnreliableRemoteEvent
- Draw remote objects smoothly with snapshot interpolation and a render delay
- Judge hand-packed buffers against schema-generated net code such as Blink and Zap
Before this: Performance: MicroProfiler, memory, network, Remotes: events, functions, unreliable, buffers
Step 1 of 10
One drone, sixty updates a second
Open DroneService at m14-ship and find the function that moves the drone. It runs on every Heartbeat, the engine's per-frame signal, for as long as a drill is active:
local function moveDrone(drone: Drone, dt: number)
local root = drone.root
local pos = Vector3.new(root.Position.X, HOVER_Y, root.Position.Z)
local rotation = root.CFrame.Rotation
local target = nearestLivingRoot(root.Position)
if target then
local flat = Vector3.new(target.Position.X - pos.X, 0, target.Position.Z - pos.Z)
local distance = flat.Magnitude
if distance > STOP_DISTANCE then
local travel = math.min(Config.DRONE_SPEED * dt, distance - STOP_DISTANCE)
local direction = flat.Unit
pos += direction * travel
rotation = CFrame.lookAt(Vector3.zero, direction).Rotation
end
end
drone.model:PivotTo(CFrame.new(pos) * rotation)
The last line is the cost. PivotTo sets the CFrame of a server-owned part in Workspace, and every property change on a replicated instance is sent to every client that has it. Roblox's performance guide names the same pattern as a common problem with server-side TweenService: the tweened property "is replicated to each client every frame"1. PivotTo on Heartbeat is a hand-written version of that.
The Performance: MicroProfiler, memory, network lesson already found this: the drone is the yard's biggest stream. This lesson fixes it, and puts every other system on a network budgetNetwork budgetA table of how many bytes per second each system may send to each player, measured and kept up to date.Think of it as a spending plan for bandwidth: every system gets a line, and the total has to fit. while it is at it.
A drill lasts Config.ROUND_SECONDS = 40, and the server's Heartbeat runs about 60 times a second. How many drone position updates does each client receive in one drill, if every Heartbeat moves the drone?
Step 2 of 10
Measure before you change anything
A budget starts with a measurement, so record the drone's cost before you touch it. Roblox gives you four views, and each answers a different question2:
- Performance Stats (Ctrl+Alt+F7 in Studio) is a toolbar with memory, CPU, GPU, network data sent and received, and ping.
- Network debug stats (Shift+F3, or Ctrl+Shift+F3 in a Studio test client) shows one client's network numbers, including data ping.
- The Server Stats tab of the Developer Console shows the average data ping of every player on the server.
- The MicroProfiler (Ctrl+Alt+F6) can record network traffic into a frame dump. Choose Network: Low or High, save a dump, and open X-Ray / Network: received traffic sits on the top row, sent on the bottom, coloured by physics, data and assets3.
Data ping matters most here. When the server makes replication data faster than the network can send it, the data waits in a queue, and data ping climbs above network ping. That is the symptom of a blown network budget.

Network debug stats during a drill at m14-ship, one drone, three test clients. This is the baseline.
Match each question to the tool that answers it.
Step 3 of 10
A budget per player, per system
A network budget is a table with one row per system and three numbers per row: bytes per message, messages per second, and the bytes per second that come out. You pick the total yourself. Roblox does not publish a number to aim for, so studios set one from their own measurements on their weakest target phone, and every new feature has to fit inside it.
Count payload bytes, the data you send. The engine adds its own headers on top, which is one more reason to measure the result in Studio instead of trusting the sum. Run this budget for a future yard with forty drones, comparing three ways to send them. Each version has a 3-byte header; the float version spends 15 bytes a drone (an id, three four-byte floats and a two-byte heading, as in the Remotes: events, functions, unreliable, buffers lesson).
At m15-scale that table is real and enforced. Config.NET_BUDGETS holds bytes per second per player for each system:
-- Network budget per player, bytes per second, by system (m15).
-- NetMeter compares each system's measured rate with these.
NET_BUDGETS = {
DroneStream = 400,
PlayerState = 200,
Feedback = 200,
RoundState = 50,
} :: { [string]: number },
NetMeter adds up what each system sends, divides by the number of players and compares the rate with its budget. In Play, every five seconds it writes one line per system to an attribute. Read it in the server's command bar: print(game.ServerScriptService.Server:GetAttribute("NetReport")).
During a drill the report reads: DroneStream 96 B/s of 400 / PlayerState 260 B/s of 200 OVER / Feedback 30 B/s of 200 / RoundState 12 B/s of 50. Where do you look first?
Press 1 to 4 to choose, Enter to check.
| In the picture | In Roblox |
|---|---|
| A new page from the server | A snapshot packet, ten times a second |
| Staying one page behind | Drawing at now minus the render delay |
| Drawing the in-between frames | Blending position and yaw between the two snapshots around the render time |
| Throwing away an old page that arrives late | Dropping a packet whose sequence number is older than the newest |
Sending ten pictures a second instead of sixty only works if the client fills the gaps. Picture a flipbook artist who receives a new page from the server ten times a second. If they show each page the moment it arrives, the drone jerks. So they stay one page behind: while page 41 is on screen, they already hold page 42 and can draw every in-between frame.
Think of it as A flipbook artist who stays one page behind the pages the server sends
One packed drone takes 10 bytes with its header. What does this print?
local bytes = 10
local perFrame = bytes * 60 / 1000
local tenHz = bytes * 10 / 1000
print(perFrame, tenHz)
Press 1 to 4 to choose, Enter to check.
Step 4 of 10
Send less often, draw in between
The client keeps the last few snapshots for each drone, each stamped with the time it arrived. On every frame it draws the drone at now minus a render delay, 0.1 s here, one packet interval. That moment almost always falls between two snapshots it already holds, so it blends them: a snapshot interpolationSnapshot interpolationDrawing a remote object a little in the past, blended between the two newest snapshots the client already has.Think of it as a flipbook artist who stays one page behind so every in-between frame can be drawn.. Before the first snapshot it holds the first, after the last it holds the last. It never guesses ahead.
The render delay is also why a swing can miss. The drone on your screen is about your ping plus 0.1 s behind the server's drone, so a swing that connects on your screen can reach the server after the drone has moved on. The next lesson, Server authority: prediction, rollback, lag-compensated hits, has a simulator for exactly that miss and shows how the server rewinds to judge the swing fairly.
Angles need care. A drone turning from 350 degrees to 10 degrees has turned 20 degrees, through 0. Blend the two numbers directly and the halfway point is 180: the drone spins all the way round for one frame.
The client blends yaw with a plain lerp. What does this print?
local function lerp(a, b, t)
return a + (b - a) * t
end
print(lerp(350, 10, 0.5))
Press 1 to 4 to choose, Enter to check.
Fix both functions below. The tests use the same snapshots as the game repo's check.
Step 5 of 10
Pack the bits
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. lets you choose how many bytes each value takes. buffer.writebits goes further: it writes a value in any number of bits from 0 to 32, at any bit offset, treating the value as an unsigned 32-bit number and keeping only the lowest bits4. To use it, every value must become a whole number in a known range first. That step is quantizationQuantizationTurning a number into a whole count of fixed steps inside a known range, so it fits in a few bits.Think of it as measuring with a ruler marked in sixteenths instead of writing every decimal..
The yard's drone needs far less precision than a float. Here is the layout the game repo's check expects:
| Field | Range | Step | Bits |
|---|---|---|---|
| sequence (header) | 0 to 65,535, wraps | 1 | 16 |
| count (header) | 0 to 63 drones | 1 | 8 |
| id | 0 to 63 | 1 | 6 |
| x and z | -256 to 255.9375 studs | 1/16 stud | 13 each |
| y | 0 to 63.875 studs | 1/8 stud | 9 |
| yaw | 0 up to 360 degrees, wraps | 360/256 | 8 |
| stunned | yes or no | 1 |
A drone is 50 bits. One drone with the header is 74 bits, which rounds up to 10 bytes.
The header is 24 bits and each drone is 50 bits. How many bytes does a packet with 40 drones need? (Round up to whole bytes.)
x is rounded to the nearest 1/16 of a stud. What is the largest error, in studs, that rounding can add to a position inside the encodable range?
Step 6 of 10
An unreliable stream, and what stays reliable
The packet goes on an UnreliableRemoteEventUnreliableRemoteEventA remote whose messages are not resent when lost and can arrive out of order; payloads over 1000 bytes are dropped.Think of it as shouting the latest position across a field: a missed shout is replaced by the next.. Its messages are not resent when lost, and they do not wait for earlier ones, so they can arrive out of order. A payload over 1,000 bytes is dropped5. For a stream where every packet replaces the one before, all three are fine, and the 253-byte packet leaves room to spare.
Out of order is the one to handle. If packet 41 arrives after packet 42, drawing it would move the drone backwards. That is what the sequence number is for: the client keeps the newest number it has seen and ignores anything older. Because the number wraps at 65,536, "older" means "behind by less than half the range", which the receiving code checks with (seq - lastSeq) % 65536.
Client sideRemember: Snapshot interpolation with a render delay is a flipbook artist who stays one page behind the pages the server sends.
The flipbook artist now also throws away any page older than the one on the easel. The server only has to keep sending the newest picture.
Which Beacon Yard messages may travel on an UnreliableRemoteEvent?
Press 1 to 5 to choose, Enter to check.
The client has drawn packet 42. Packet 41 arrives late. What should it do?
Press 1 to 4 to choose, Enter to check.
Step 7 of 10
Build it: the drone as data
The bigger change is on the server. At m14-ship, the engine replicates the drone model in Workspace. At m15-scale, the server keeps the position, yaw, health and stun deadline in a table. Clients build their own drone models from the stream. This excerpt shows the original reliable remotes.
local REMOTE_NAMES: { string } = { "RoundState", "Feedback", "ShopOpen", "ShopBuy", "Swing", "SetSetting" }
type RemoteArg = string | number | boolean | Vector3 | nil
The sender aims for ten sends per second on Heartbeat. It caps the leftover time after a long stall.
local function sendSnapshots(dt: number)
sendClock += dt
if sendClock < SEND_INTERVAL then
return
end
-- Subtract, do not reset, so the leftover keeps the average at 10 Hz;
-- after a long stall do not catch up with a burst.
sendClock = math.min(sendClock - SEND_INTERVAL, SEND_INTERVAL)
seq = (seq + 1) % 65536
local now = workspace:GetServerTimeNow()
sentAt[seq % SENT_SLOTS] = now
sentSeq[seq % SENT_SLOTS] = seq
local list = liveDrones()
src/shared/DronePacket.luausrc/server/Remotes.luausrc/server/DroneService.luausrc/server/NetMeter.luau
Add
DroneStreamtoUNRELIABLE_NAMESand create it inRemotes.init. Retrieve it withRemotes.getUnreliable("DroneStream"). UseDronePacketto pack the sequence number and drone rows.You should see ReplicatedStorage.Remotes holds DroneStream next to nine RemoteEvents.
Keep the position, yaw, health and stun deadline in
DroneService. Publish health onReplicatedStorage.DroneState. The attribute names for slots one through three areHealth,Health2andHealth3. A drill uses only slot one atm15-scale.setWavearrives atm16-design-passwith a cap of three.You should see The server moves a drone table on Heartbeat and owns the touch damage and stun checks.
After moving the drones on
Heartbeat, callsendSnapshots(dt). Pack positions relative toDronePacket.YARD_CENTER, send only a viewer's relevant drones withFireClient, and record payload bytes withNetMeter.sent. Skip the send when the viewer has no relevant drones.You should see An in-range viewer receives about ten 10-byte payloads per second during a drill with one drone.
Why does sendSnapshots subtract SEND_INTERVAL from sendClock instead of setting sendClock back to 0?
Press 1 to 4 to choose, Enter to check.
Step 8 of 10
Build it: the client draws the drone
The receiver keeps a short history per drone and draws on RenderStepped:
local function render()
local now = os.clock()
local renderTime = now - Config.DRONE_INTERP_DELAY
for id, track in tracks do
local folder = state
local health = if folder ~= nil then folder:GetAttribute(DroneVisual.healthAttribute(id)) else nil
if now - track.lastAt > TIMEOUT_SECONDS or typeof(health) ~= "number" then
removeBody(track)
tracks[id] = nil
continue
end
local at = DronePacket.interpolate(track.snapshots, renderTime)
if at == nil then
continue
end
local pivot = CFrame.new(at.x, track.y, at.z) * CFrame.Angles(0, math.rad(at.yaw), 0)
local body = ensureBody(track, pivot)
body.model:PivotTo(pivot)
body.root:SetAttribute("StunnedUntil", if track.stunned then workspace:GetServerTimeNow() + 1 else 0)
DroneVisual.paint(body, track.colors, track.stunned, health / Config.DRONE_MAX_HEALTH)
lastDrawn = pairAt(track, renderTime)
The yaw convention has to match on both sides. CFrame.Angles(0, θ, 0) looks along (-sin θ, 0, -cos θ), so the server stores yaw = math.deg(math.atan2(-dir.X, -dir.Z)) % 360 for a chase direction dir.
src/client/DroneClient.luausrc/client/init.client.luausrc/shared/DroneVisual.luausrc/server/CombatService.luau
Start
DroneClientininit.client.luau. Keep four snapshots per drone and draw 0.1 s behind usingConfig.DRONE_INTERP_DELAY.DroneVisual.buildcreates the body. Remove its track after 0.5 s without a snapshot or when health disappears. The first packet after more than 0.5 s of stream silence can establish a new sequence baseline.You should see The client draws and paints its own drone from the stream and health attribute.
Use the history and the radius-two sphere check in
CombatService.droneHit.trySwingcompares the distance to the drone's centre with the actual raycast distance to a crawler. That comparison approximates which target the swing touches first.You should see A swing at a drone can hit without any drone part on the server.
Start a Server & Clients test with three clients and run a drill. Record the same Network debug stats and MicroProfiler Network views as at
m14-ship. Compare the measured totals with the payload budget.You should see The two captures give you a before and after for data received per second.
After the change, why can CombatService no longer use workspace:Raycast to find the drone, and what keeps the hit check on the server?
Press 1 to 4 to choose, Enter to check.
Step 9 of 10
Let a schema write the code
Hand-packing works, and it shows you exactly where the bytes go. It also means two pieces of code (pack and unpack) that must agree forever, for every message in the game. Networking libraries solve that with a schema: you describe each message once, and a compiler writes both sides. Here is the drone stream in Blink's language6:
option ServerOutput = "src/server/Net.luau"
option ClientOutput = "src/client/Net.luau"
struct DroneSnap {
Id: u8(0..63),
X: i16,
Y: u16,
Z: i16,
Yaw: u8,
Stunned: boolean
}
event DroneStream {
From: Server,
Type: Unreliable,
Call: SingleSync,
Data: (u16, DroneSnap[..63])
}
Blink's numbers take whole bytes (u8 is one, i16 two), so you still quantize the position yourself: x and z as sixteenths of a stud in an i16, and y as eighths of a stud in a u16. Its unreliable events carry the same 1,000-byte limit, and it validates what clients send before your code sees it.
Other ways pros do this
| Option | What it is | When pros pick it | Trade-offs |
|---|---|---|---|
| Plain remotes | RemoteEvent and UnreliableRemoteEvent with Luau tables. | Most messages: rare, small, or changing game state once. | Easy to read; tables carry their structure, so a high-rate stream costs more than it needs to. |
| Hand-packed buffer | buffer.writebits with your own layout, as in this lesson. | One or two hot streams where every bit counts. | Smallest packets; you maintain pack and unpack by hand and test that they agree. |
| Blink | An IDL compiler that writes buffer networking code from a schema (github.com/1Axen/blink, MIT, release v0.18.9, active as of 2026-11-25). | Many typed messages and a team that wants one source of truth. | A build step and generated files; whole-byte fields unless you pack yourself. |
| Zap | A schema compiler for buffer networking that inspired Blink's range syntax (github.com/red-blox/zap, MIT, release v0.6.29, last push 2026-06-23). | The same job as Blink, if its syntax or output suits you. | Pushed less often than Blink this year; check its changelog before adopting. |
| ByteNet, Warp | Runtime buffer libraries with no compile step. | You want packing without a schema compiler. | ByteNet's last push was 2025-08; Warp is in pre-release. Mention, do not build on them without checking. |
Your yard now has 30 message types. What is the strongest reason to move them to a schema compiler such as Blink?
Press 1 to 4 to choose, Enter to check.
Where does it break?“A flipbook artist who stays one page behind the pages the server sends” is a good picture of snapshot interpolation with a render delay. Where does it stop being true?
It breaks here. Pages stop coming for longer than the delay: the artist has nothing to draw towards, so the drone holds still and then jumps when packets return.
The true model. Interpolation only hides gaps up to the render delay. Longer stalls need a longer delay (more lag for everyone), extrapolation (guessing ahead, sometimes wrong) or a visible catch-up.
A player's connection stalls and no drone packet arrives for 0.5 s. With this lesson's interpolate, what does that client draw during the stall?
Press 1 to 4 to choose, Enter to check.
Step 10 of 10
Challenges and recap
Level 1, Apprentice
Challenge
Measure Beacon Yard at m14-ship during a drill and write its network budget as a table in a Markdown file.
- Start from
- The game at milestone m14 (download)
Done means
- A budget table lists the drone stream, RoundState, Feedback and ShopBuy with bytes per message and messages per second
- It has a baseline capture from Network debug stats or a MicroProfiler Network dump during a drill
- It names one system you would change first and why
Meet the criteria above, then record your own result. No test grades this check.
Level 2, Builder
Challenge
Fix lerpYaw and interpolate in the interp-cell Run above.
- Start from
- The game at milestone m14 (download)
- Check it here
- Run the code cell; the challenge completes when it passes. No Studio needed.
Done means
- lerpYaw takes the short way round and returns 0 to 360
- interpolate blends between the two snapshots around renderTime and holds at both ends
- Every test in interp-cell passes
Your budget table for Beacon Yard at m14-ship shows the drone stream, RoundState, Feedback and ShopBuy. Which row should you change first?
Press 1 to 4 to choose, Enter to check.
Level 3, Professional
Challenge
Write the packer, the reader and the interpolation in the game repo's challenges/work/drone_packet.luau, then run the network-budget challenge through the Course Runner.
- Start from
- The game at milestone m14 (download)
- Grade it
- In Studio, press Play, then run
game.ServerScriptService.RunGameTests:Invoke("network-budget")in the server command bar. Copy the pass code from Output.
Done means
- challenges/work/drone_packet.luau packs one drone in 10 bytes and forty in 253
- unpack returns every drone within half a step, with the sequence number, and clamps out-of-range values to the edge
- lerpYaw and interpolate pass the same cases as the Run cell
- The network-budget challenge prints TEST PASS for all fourteen checks
Retiring the analogy
You no longer need “a flipbook artist who stays one page behind the pages the server sends”. Interpolation only hides gaps up to the render delay. Longer stalls need a longer delay (more lag for everyone), extrapolation (guessing ahead, sometimes wrong) or a visible catch-up.
Recap
- Every property the server changes on a replicated part goes to every client; the drone's PivotTo on Heartbeat is 60 updates a second per player.
- A network budget lists bytes per message and messages per second for each system, measured with Performance Stats, Shift+F3, Server Stats and MicroProfiler Network dumps.
- Send moving objects at 10 to 20 Hz on an UnreliableRemoteEvent, drop packets older than the newest, and interpolate 0.1 s behind; payloads over 1,000 bytes are dropped.
- Quantize and bit-pack with buffer.writebits: forty drones fit in 253 bytes, about 2.5 KB/s at 10 Hz instead of 36 KB/s per frame.
- Schema compilers such as Blink and Zap write pack and unpack from one description; hand-pack only the hottest streams.
Snapshot interpolation with a render delay is a flipbook artist who stays one page behind the pages the server sends, until pages stop coming for longer than the delay: the artist has nothing to draw towards, so the drone holds still and then jumps when packets return.
Queued for review
- A drill lasts Config.ROUND_SECONDS = 40, and the server's Heartbeat runs about 60 times a second. How many drone position updates does each client receive in one drill, if every Heartbeat moves the drone?
- The client blends yaw with a plain lerp. What does this print?
- The header is 24 bits and each drone is 50 bits. How many bytes does a packet with 40 drones need? (Round up to whole bytes.)
- The client has drawn packet 42. Packet 41 arrives late. What should it do?
Next Server authority: prediction, rollback, lag-compensated hits