Boot order: what runs first

Learn what runs first in a Roblox game. Beacon Yard's server entry script, its written start order, why the wrench exists before the map, how clients wait for the server, and the ReplicatedFirst loading screen.

Concept lesson, about 65 minutes, 9 steps

By the end you can

  • Read init.server.luau as two lists, the requires and the start calls, and say why they differ
  • Explain why the wrench is created before any call that can yield
  • Describe what the ReplicatedFirst loading script waits for, and how long it waits at most

Before this: Client and server: who owns what, ModuleScripts and require

Step 1 of 9

The player who spawned with nothing in their hand

Imagine you join Beacon Yard a split second after the server starts. The map is still being built and the data store is still loading. Your character spawns. Roblox copies everything in StarterPack into your backpack when a character spawns. If the wrench was not in StarterPack yet, that character spawns with an empty hotbar, and nothing is wrong in any log. StarterPack is copied again on every respawn, so a missed tool costs one life, not forever.

That is a boot-order bug: the right code, run in the wrong order. Beacon Yard's server avoids it with one short list. CombatService.start also has a repair: it gives the wrench to players already in the game and again on every CharacterAdded. Treat that as a safety net, since starting first means nobody ever needs it.

Remotes.init()
WorldLook.start()
-- The wrench has to exist before the first character spawns. MapBuilder
-- and DataService can yield, and StarterPack only copies tools at spawn.
CombatService.start()
local map = MapBuilder.build()
DataService.start()
MonetizationService.start()
CoinService.start(map.pads)
ShopService.start(map.shopPrompt)
local drone = DroneService.start(map.droneSpawn)
RoundService.start({
	prompt = map.beaconPrompt,
	gateLeft = map.gateLeft,
	gateRight = map.gateRight,
	setDroneActive = drone.setActive,
})
ExhibitService.start(map.yard)
TeamService.start()
AnnounceService.start()
PolicyProbe.start()
Choose one

StarterPack copies its tools into a character's backpack when the character spawns. CombatService.start puts the Wrench into StarterPack. Where in the start list should it sit so the very first character already has the wrench?

StarterPack copies its tools into a character's backpack when the character spawns. CombatService.start puts the Wrench into StarterPack. Where in the start list should it sit so the very first character already has the wrench?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 2 of 9

Two lists: require, then start

The server entry script has a block of require lines at the top and a block of start calls below. You met the difference in the modules lesson: a require only runs a module's body, which defines functions and builds tables. A start call is where a service does anything at all: connects events, builds parts, opens the store.

Both sidesBoot order is the opening checklist for the arena.
In the pictureIn Roblox
Unlocking the doors firstRemotes.init creating the folder everything else uses
Lights on before the crowd entersWorldLook.start setting the lighting before the round stores it
Staff at their posts before the whistleThe wrench in StarterPack before any call that can yield
The checklist itselfThe written start list in init.server.luau

See the whole analogy cast

Starting a game server is opening an arena for the evening. The checklist says which door to unlock first, which lights to turn on before the crowd enters, and who must be at their post before the referee blows the whistle.

Think of it as The opening checklist for the arena

The two lists are allowed to disagree. WorldLook is required tenth of fourteen and started second. MonetizationService is required last and started after DataService, not last.

Roblox Studio
Roblox Studio with the Server script open: the require block, then Remotes.init, WorldLook.start, a comment about the wrench, CombatService.start, MapBuilder.build and DataService.start.

Select a numbered pin, or a row below, to read what it marks.

The Server script in Studio. Read down the start calls, not the require lines.

Put in order

Put these m06 calls in the order init.server.luau runs them.

  1. WorldLook.start()
  2. MapBuilder.build()
  3. Remotes.init()
  4. CoinService.start(map.pads)
  5. DataService.start()
  6. CombatService.start()

Link to this step · This confused me

Step 3 of 9

Watch the two lists in a model

The cell below is a toy version of the boot script: three fake services that log when they are required and when they start. The log shows that the order of the requires does not decide the order of the work.

Luau
Ctrl Enter runs the cell. Checked against the expected output

Now swap two of the start calls and run it again. The required: lines stay where they were, because only the start block decides the order of the work.

Choose one

In m06, WorldLook is required near the end of the require block. What time does it run its work?

In m06, WorldLook is required near the end of the require block. What time does it run its work?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 4 of 9

Each call earns its place

Every position in the list has a reason, usually "this needs that":

  • Remotes.init first. It creates the ReplicatedStorage.Remotes folder. Every later service fires remotes, and clients wait for that folder.
  • WorldLook.start second. It sets the dusk lighting. The round stores the current clock when it starts, so the lighting has to be right before then.
  • CombatService.start before the map. The wrench has to be in StarterPack before any yield.
  • MapBuilder.build before the services that need the map. It returns the pads, the prompts, the gates and the drone spawn.
  • DataService.start before anything that reads profiles, including coins, the shop and the receipt handler.
  • DroneService.start before RoundService.start, because the round receives the drone's setActive function.

Both sidesRemember: Boot order is the opening checklist for the arena.

Match the pairs

Match each start call to the thing it must wait for.

Link to this step · This confused me

Step 5 of 9

The client waits for the server

The client has the same problem in mirror. Its scripts start while the server may still be setting up. Hud.luau does ReplicatedStorage:WaitForChild("Remotes"), and WaitForChild yields until the folder exists. A client script that skipped the wait would index a folder that is not there yet.

Roblox also gives clients a head start: anything in ReplicatedFirst is sent before the rest of the game, so a loading screen can show while everything else arrives. Beacon Yard's loading script removes the default screen, shows its own, then polls until the game is loaded and the Remotes folder exists, for at most 8 seconds1.

local TIMEOUT_SECONDS = 8
 
local player = Players.LocalPlayer
local deadline = os.clock() + TIMEOUT_SECONDS
local playerGui = player:WaitForChild("PlayerGui", TIMEOUT_SECONDS)
 
if playerGui == nil then
	ReplicatedFirst:RemoveDefaultLoadingScreen()
	return
end
 
local gui = Instance.new("ScreenGui")
gui.Name = "BeaconYardLoading"
gui.ResetOnSpawn = false
gui.DisplayOrder = 100
gui.IgnoreGuiInset = true
gui.Parent = playerGui
 
local sharedFolder = ReplicatedStorage:FindFirstChild("Shared")
local scaleModule = sharedFolder and sharedFolder:FindFirstChild("UiScale")
if scaleModule and scaleModule:IsA("ModuleScript") then
	local UiScale = require(scaleModule) :: { attach: (gui: ScreenGui) -> () }
	UiScale.attach(gui)
end
 
local frame = Instance.new("Frame")
frame.Name = "Backdrop"
frame.Size = UDim2.fromScale(1, 1)
frame.BackgroundColor3 = Color3.fromRGB(16, 20, 26)
frame.BorderSizePixel = 0
frame.Parent = gui
 
local title = Instance.new("TextLabel")
title.Name = "Title"
title.BackgroundTransparency = 1
title.Size = UDim2.fromScale(1, 1)
title.FontFace = Font.new("rbxasset://fonts/families/BuilderSans.json", Enum.FontWeight.ExtraBold)
title.TextSize = 48
title.TextColor3 = Color3.fromRGB(236, 232, 214)
title.Text = "Beacon Yard"
title.Parent = frame
 
ReplicatedFirst:RemoveDefaultLoadingScreen()
 
while os.clock() < deadline do
	local remotes = ReplicatedStorage:FindFirstChild("Remotes")
	if game:IsLoaded() and remotes ~= nil then
		break
	end
	task.wait(0.05)
end
 
gui:Destroy()
Work it out

The loading script polls every 0.05 seconds with task.wait(0.05) and gives up after TIMEOUT_SECONDS. At most, how many polls can happen? (Assume each task.wait takes exactly 0.05 seconds.)

polls

Link to this step · This confused me

Step 6 of 9

Where the checklist picture breaks

A real opening checklist is done by one person who walks through it. Server and client boot in parallel on two machines, and the engine can run other scripts at any yield. The client has no way to know the server finished its list; it can only wait for something observable.

Where does it break?“The opening checklist for the arena” is a good picture of boot order. Where does it stop being true?

It breaks here. A real checklist is walked through by one person. The server and every client boot at the same time on different machines, the engine can run other scripts at any yield, and a client cannot see the server's list: it can only wait for something that replicates.

The true model. Boot order is the order of start calls in one entry script per side. Any call that yields lets the engine run other work, including spawning characters, so what must exist early goes before the first yield, and clients wait on replicated signals such as a folder appearing.

Choose one

Which of these is a signal the client can actually observe to know the server's Remotes.init has run?

Which of these is a signal the client can actually observe to know the server's Remotes.init has run?

Press 1 to 4 to choose, Enter to check.

Link to this step · This confused me

Step 7 of 9

Build it: mark the order, then read it back

Pros keep boot order explicit and testable. Here are the shapes you will meet.

Ways to order startup

OptionWhat it isWhen pros pick itTrade-offs
One entry script with explicit start callsA written list, as in init.server.luau.Small and mid-size games, and any team that wants to read boot order in one file.You maintain the list by hand; forgetting a start call fails quietly.
Lifecycle hooks (Init, then Start)Frameworks such as the archived Knit call every service's Init first, then every Start.Codebases that grew many services with cross-dependencies.Hides order behind conventions, and Knit is archived.
Dependency injectionEach module declares what it needs and a loader starts things in dependency order.Large studios with many packages.More machinery to learn and debug.
Auto-load every ModuleScript in a folderA loop requires and starts everything it finds.Teams that want no boilerplate.Start order becomes the order of children, which changes without warning.

Build along

m06-drone-wrench

  • src/server/init.server.luau
  1. Check out the tag with git checkout m06-drone-wrench, run rojo serve and connect the plugin.

    You should see Studio shows the Server script under ServerScriptService, with the services as its children.

  2. In src/server/init.server.luau, add print("boot remotes") on the line before Remotes.init() and print("boot policy") on the line after PolicyProbe.start(). Press Play and filter Output to the server.

    You should see Output shows boot remotes first and boot policy last, both from the server.

  3. Stop and remove both prints with git checkout -- src/server/init.server.luau.

    You should see git status shows a clean working tree.

Link to this step · This confused me

Step 8 of 9

Challenges

Level 1, Apprentice

Challenge

Write the server start order from memory, then check it.

Start from
The game at milestone m06 (download)

Done means

  • You write the start list from Remotes.init through PolicyProbe.start from memory
  • You mark which calls have a comment explaining their position

Meet the criteria above, then record your own result. No test grades this check.

Find the broken line

This client snippet works in Studio on your fast machine and fails for some real players. Which line is the bug?

This client snippet works in Studio on your fast machine and fails for some real players. Which line is the bug?

Press 1 to 4 to choose, Enter to check.

Level 2, Builder

Challenge

Find where the client waits for the server, and say what breaks without the wait.

Start from
The game at milestone m06 (download)

Done means

  • You open src/client/init.client.luau and src/client/Hud.luau
  • You find the line where the client waits for the Remotes folder
  • You explain what would happen if it used FindFirstChild instead of WaitForChild

Meet the criteria above, then record your own result. No test grades this check.

Level 3, Professional

Challenge

Leave a mark in the live server that the wrench started before the map. The solution is challenges/solutions/boot-order.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 run game.ServerScriptService.RunGameTests:Invoke("boot-order") in the server command bar. Copy the pass code from Output.

Done means

  • init.server.luau sets workspace attribute WrenchBeforeMap to true
  • Self-check, the test cannot see it: the attribute is set on the line after CombatService.start() and before MapBuilder.build(), and the wrench still starts before the map
  • The Course Runner prints TEST PASS boot_wrench_before_map and a pass code

The Course Runner prints this code when the test passes.

Link to this step · This confused me

Step 9 of 9

Recap

Retiring the analogy

You no longer need “the opening checklist for the arena”. Boot order is the order of start calls in one entry script per side. Any call that yields lets the engine run other work, including spawning characters, so what must exist early goes before the first yield, and clients wait on replicated signals such as a folder appearing.

Recap

  1. init.server.luau has two lists. Requires only run module bodies; the start calls do the work, in an order written by hand, so WorldLook can be required late and started second.
  2. Each position has a reason: Remotes before anything that fires, the wrench before any call that yields, the map before what needs its parts, data before anything that reads profiles.
  3. The client cannot see the server's list. It waits for something that replicates, such as the Remotes folder, and ReplicatedFirst lets a loading screen run before the rest arrives, for at most 8 seconds.

Boot order is the opening checklist for the arena, until a real checklist is walked through by one person. The server and every client boot at the same time on different machines, the engine can run other scripts at any yield, and a client cannot see the server's list: it can only wait for something that replicates.

Next Remotes: events, functions, unreliable, buffers

Link to this step · This confused me