Debugging: breakpoints, the console, a method

Debug a Roblox game like a pro. Pause Beacon Yard's server code on a breakpoint, read Watch and the Call Stack, use logpoints and the F9 Developer Console, and follow a repeatable method.

Tool lesson, about 75 minutes, 12 steps

By the end you can

  • Pause CombatService.trySwing on a server breakpoint and read Watch and the Call Stack
  • Choose between a breakpoint, a conditional breakpoint and a logpoint for a noisy event such as Touched
  • Read Output and the Developer Console and tell a Luau error from an engine content warning
  • Follow a five-step method from symptom to a fix that a test keeps fixed

Before this: Client and server: who owns what, Playtesting: Play, Run, Team Test, server and client views

1A swing that does nothing

You swing the wrench at the drone. The animation plays, the sound plays, and the drone's health bar does not move. Nothing is red in Output. Somewhere between your click and the drone, a rule said no.

In Beacon Yard that rule lives in CombatService.trySwing, on the server. It returns one of three words: rejected, miss or hit. Your job is to find out which one it returned, and why.

function CombatService.trySwing(player: Player, origin: unknown, direction: unknown): string
	if typeof(origin) ~= "Vector3" or typeof(direction) ~= "Vector3" then
		return "rejected"
	end
	if not isFiniteVector(origin) or not isFiniteVector(direction) then
		return "rejected"
	end
	if direction.Magnitude < 1e-3 then
		return "rejected"
	end
 
	local character = player.Character
	if character == nil then
		return "rejected"
	end
	local tool = character:FindFirstChild("Wrench")
	if tool == nil or not tool:IsA("Tool") then
		return "rejected"
	end
	local head = character:FindFirstChild("Head")
	if head == nil or not head:IsA("BasePart") then
		return "rejected"
	end
	if (origin - head.Position).Magnitude > ORIGIN_MAX_STUDS then
		return "rejected"
	end
 
	local now = workspace:GetServerTimeNow()
	local previousSwing = lastSwing[player]
	if previousSwing ~= nil and now - previousSwing < SWING_GAP then
		return "rejected"
	end
	lastSwing[player] = now
 
	feedback(player, "swing", nil)
 
	local params = RaycastParams.new()
	params.FilterType = Enum.RaycastFilterType.Include
	params.FilterDescendantsInstances = CollectionService:GetTagged(DRONE_TAG)
 
	local result = workspace:Raycast(origin, direction.Unit * Config.WRENCH_RANGE, params)
Figure 1.1

The first line of the function checks the types of what the client sent. Seven more checks follow before the ray is cast. Any of them can end the swing quietly.

trySwing returns a string. Which value means a server check refused the swing before any ray was cast?

  1. rejected
  2. miss
  3. hit
  4. nil
Answer

rejected. Every early exit returns "rejected". miss means the ray hit nothing tagged Drone, and hit means damage was applied.

Open this step in lesson mode · Link to this step · This confused me

2Which side is paused?

Studio runs two simulations when you press Play: a server and a client1. A BreakpointBreakpointA mark on a line of code that pauses the script when that line is about to run.Think of it as a pause button glued to one line. pauses only the side that runs that line. trySwing is server code, so a breakpoint on it stops the server while your character, camera and HUD keep going on the client.

The viewport border tells you which view you are looking at: green for the server, blue for the client. Output labels each line the same way.

The server is the referee with the only real scoreboard. When you pause the referee, the players can still run around their screens. Nothing they do counts until the referee resumes.

Think of it as The referee with the only real scoreboard

Server sideRemember: The server is the referee with the only real scoreboard.

You set a breakpoint on the first line of CombatService.trySwing and swing. What happens?

  1. The server pauses; your client keeps rendering, but nothing the server owns changes
  2. The whole Studio window freezes, client included
  3. Nothing, because breakpoints only work in LocalScripts
  4. The client pauses and the server keeps running
Answer

The server pauses; your client keeps rendering, but nothing the server owns changes. A breakpoint pauses the side that executes the line. trySwing runs on the server, so the server pauses and the client keeps drawing frames.

Open this step in lesson mode · Link to this step · This confused me

3Pause on the line

You already met gutter breakpoints, Watch, Call Stack and the F10 / F11 / Shift+F11 stepping keys in Debugging basics: Output, stack traces and breakpoints. Here they pause a live server remote handler in trySwing.

Roblox Studio
Roblox Studio paused on the first check of CombatService.trySwing, with the Call Stack panel at the bottom left and the Watch panel at the bottom right.

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

Figure 3.1.

A server breakpoint in trySwing. Watch has four expressions; two of them read Value not found.

In Watch2, origin already holds the Vector3 the client sent, while head is assigned further down the function and reads Value not found until you step past it. In Call Stack, trySwing sits above the Swing remote handler (a real player click) rather than tests/init.luau (a direct test call).

Paused on the first line of trySwing, you add (origin - head.Position).Magnitude to Watch. What does it show?

function CombatService.trySwing(player, origin, direction)
	-- paused here
	...
	local head = character:FindFirstChild("Head")
  1. Value not found, because head is not assigned yet
  2. The distance from the head to the origin
  3. 0
  4. An error that stops the playtest
Answer

Value not found, because head is not assigned yet. head is assigned later in the function. Step with F10 until that line has run, then the expression resolves.

Open this step in lesson mode · Link to this step · This confused me

4Step, then continue

Using the stepping keys from Debugging basics: Output, stack traces and breakpoints (F10 over, F11 into, Shift+F11 out, plus Resume)2, walk through a real wrench swing on the server:

Figure 4.1.

A server breakpoint hit by a real wrench swing, then Watch, the Call Stack and Resume.

Transcript
  1. 0:01 The server breakpoint in trySwing hits when the wrench swings.
  2. 0:06 Watch shows the origin the client sent, and its magnitude. head reads Value not found. That local is not assigned yet.
  3. 0:14 The call stack is the Swing remote, then trySwing.
  4. 0:25 Continue, and the server runs again.

Build along

m06-drone-wrench

  • src/server/CombatService.luau
  1. Open CombatService in Studio (synced from src/server/CombatService.luau) and click in the gutter next to the first line inside trySwing.

    You should see A red circle appears in the gutter next to the first line of trySwing.

  2. Press Play, equip the wrench, and swing once.

    You should see Play pauses on that line with a yellow arrow. The Call Stack lists trySwing above the Swing handler.

  3. In Watch, add origin, origin.Magnitude and head. Press F10 a few times and watch head change.

    You should see origin shows a Vector3. head reads Value not found until you step past the line that assigns it.

  4. Press Resume, then Stop.

    You should see The swing finishes and Play continues. Stop resets the place, but the breakpoint stays in the gutter.

Open this step in lesson mode · Link to this step · This confused me

5Touched fires a lot: use a logpoint

Some code runs dozens of times a second. CoinService's Touched handler fires for every body part that bumps the coin. A plain breakpoint there freezes the server on every foot, including all the touches that are fine.

Studio has three other gutter marks for this2:

  • A conditional breakpoint pauses only when an expression is true, such as (rootPart.Position - coin.Position).Magnitude > 12, the reject path.
  • A LogpointLogpointA breakpoint that writes a message to Output instead of pausing.Think of it as a print you add from the gutter, without editing the script. prints a message to Output and does not pause.
  • A temporary breakpoint removes itself after one playtest.
Roblox Studio
Studio's script editor on CoinService line 126 with a red logpoint diamond in the gutter, and the Output pane below it, filtered to distance, listing one 'distance:' line for each touch with the value in studs.

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

Figure 5.1.

A logpoint on line 126 writes each distance to Output and the game keeps running.

Roblox Studio
Studio's Edit Breakpoint dialog for CoinService line 126, with Enabled ticked and the condition (rootPart.Position - coin.Position).Magnitude > 12 typed into the Condition field.

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

Figure 5.2.

Right-click a breakpoint and choose Edit Breakpoint to give it a condition.

		-- A touch is only a hint. Check the character's root is close
		-- enough to the coin before paying.
		local character = player.Character
		local rootPart = if character then character:FindFirstChild("HumanoidRootPart") else nil
		if rootPart == nil or not rootPart:IsA("BasePart") then
			return
		end
		if (rootPart.Position - coin.Position).Magnitude > 12 then
			return
		end
		seen[player] = true
Figure 5.3

Match each debugging goal to the gutter mark that fits it.

  1. See every coin distance while you keep walking
  2. Stop only when a coin touch is refused for distance
  3. Check one value once today and forget about it
  4. Stop the first time a swing reaches trySwing
Answer

See every coin distance while you keep walking: Logpoint; Stop only when a coin touch is refused for distance: Conditional breakpoint; Check one value once today and forget about it: Temporary breakpoint; Stop the first time a swing reaches trySwing: Standard breakpoint. A logpoint logs and keeps going. A condition limits the pause to the case you care about. A temporary breakpoint deletes itself after the playtest. A standard one always pauses.

Open this step in lesson mode · Link to this step · This confused me

6Output, F9 and what a line is telling you

You already used Studio's Output window (print, warn and red errors) in Debugging basics: Output, stack traces and breakpoints3. The Developer Console opens with F9 or /console in any running session, including a published game, and adds Memory, Network and Script views4. In a live server only the owner and editors can read the server log.

Roblox Studio
The Developer Console open during Play on a published place, showing the server log tab with a content warning and an analytics line.

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

Figure 6.1.

F9 during Play. The lines in view name an asset and a service, not a script in src/.

Learn to read the shape of a line before its words:

  • A Luau error names a script and a line: ServerScriptService.Server.CombatService:162. That is your code.
  • An engine content warning names an asset id and no script. Often it is not your request at all; in Beacon Yard one comes from the default avatar.
  • A game warning is text the game chose to write. DataService warns once when the store is unavailable, then carries on.
local function warnOnce(message: string)
	if warned then
		return
	end
	warned = true
	warn(message)
Figure 6.2

Match each Output line to what it most likely is.

  1. ServerScriptService.Server.CoinService:126: attempt to index nil with 'Position'
  2. Failed to load sound rbxassetid://... (no script named)
  3. DataStore unavailable (...). Profiles stay in server memory for this session.
  4. TEST PASS coin_pickup
Answer

ServerScriptService.Server.CoinService:126: attempt to index nil with 'Position': A Luau error in your server code; Failed to load sound rbxassetid://... (no script named): An engine content warning; DataStore unavailable (...). Profiles stay in server memory for this session.: A warning the game wrote on purpose; TEST PASS coin_pickup: A print from the test suite. Only a line with a script path and a number points into your code. The DataStore line is DataService.warnOnce, and TEST PASS lines are printed by tests/init.luau.

Open this step in lesson mode · Link to this step · This confused me

7The command bar trap

The command bar runs Luau you type, on the server or the client. It also has its own require cache. If you require DataService from it, you do not get the running service; you get a second, fresh copy with no profiles. The HUD shows 85 coins and your command-bar copy says the player has no profile at all. You can see it yourself in a solo Play session. In the server command bar, game.Players:GetPlayers()[1] is the player Studio spawned, so this line asks the fresh copy about that player:

luau
require(game.ServerScriptService.Server.DataService).get(game.Players:GetPlayers()[1])

It errors with No profile for and the player's name, even though the running game has a profile for them.

Beacon Yard avoids this by letting the server script require the test suite and expose a BindableFunctionBindableFunctionAn object that lets scripts on the same side call each other and get a result back.Think of it as an intercom between two rooms in the same building. called RunGameTests. Invoking it runs code inside the live server's cache.

-- The Studio command bar has its own require cache, so a test that
-- requires these services from the command bar would get a second,
-- empty copy. Requiring the suite here binds it to this script's cache.
-- Invoke ServerScriptService.RunGameTests from the command bar to run it.
local testModule = ReplicatedStorage:FindFirstChild("GameTests")
if testModule and testModule:IsA("ModuleScript") then
	local runTests = require(testModule) :: () -> ()
	local runner = Instance.new("BindableFunction")
	runner.Name = "RunGameTests"
	runner.Parent = ServerScriptService
Figure 7.1

During Play you run require(game.ServerScriptService.Server.DataService).get(game.Players:GetPlayers()[1]) from the server command bar. It errors with No profile. Why?

  1. The command bar has its own require cache, so it built a second DataService with no profiles
  2. DataService only works on the client
  3. The player has not touched a coin yet
  4. The DataStore is unavailable in Studio
Answer

The command bar has its own require cache, so it built a second DataService with no profiles. One per require cache. The running server has one copy; the command bar made another. Invoke a bindable the server script created to reach the live copy.

Open this step in lesson mode · Link to this step · This confused me

8Monitoring errors on live servers

Once players join a published experience, you cannot set a breakpoint on their server. Instead, open Creator Dashboard > Creations, pick your experience, and under Monitoring select Error Report5.

Error Report aggregates up-to-the-minute Luau errors and warnings from both servers and clients. Key tools on the page:

  • Filters: narrow by Date range (1 hour to 30 days), Place, Severity, Platform, OS, Show version (marks each place publish on the chart) and New errors since (isolates regressions introduced in a specific version).
  • Errors and warnings table: shows Count, Severity, Type (server or client), Message, First seen at and First seen version. Expand any row with a dropdown to inspect its stack trace.
  • Custom rules: on the Rules tab, click Create Rule to match exact text or a regex and either Ignore unavoidable noise or Group related messages under one label.

To make live logs searchable and easy to group, write structured warnings with a fixed tag prefix and key=value fields instead of free-form sentences:

Luau
-- Consistent key=value formatting makes Error Report search and Group rules easy.
local function formatLog(tag: string, event: string, fields: { { string } }): string
	local parts = { "[" .. tag .. "]", "event=" .. event }
	for _, pair in fields do
		table.insert(parts, pair[1] .. "=" .. pair[2])
	end
	return table.concat(parts, " ")
end
 
print(formatLog("CombatService", "swing_rejected", { { "reason", "too_far" }, { "dist", "14.2" } }))
print(formatLog("DataService", "save_retry", { { "attempt", "2" }, { "status", "throttled" } }))
Figure 8.1. Expected output: [CombatService] event=swing_rejected reason=too_far dist=14.2 [DataService] event=save_retry attempt=2 status=throttled

You just published version 48 of Beacon Yard. Which Error Report options help you spot errors that started only in version 48?

  1. Turn on Show version and filter with New errors since
  2. Set a server breakpoint in Studio
  3. Filter by OS only
  4. Ignore every warning on the Rules tab
Answer

Turn on Show version and filter with New errors since. Show version marks publishes on the error chart, and New errors since filters the table down to messages first seen after a chosen version.

Open this step in lesson mode · Link to this step · This confused me

9A method you can repeat

Tools help only inside a method. Professionals use something close to this:

  1. Reproduce. Find the smallest steps that make the bug happen every time.
  2. Locate the side. Server or client? The colour of the Output line and the folder of the script tell you.
  3. Form one guess. "The origin is more than 8 studs from the head."
  4. Test the guess with one breakpoint, logpoint or print. Read the value; do not assume it.
  5. Fix and lock it in with a test that fails without your fix.

Step 5 is what separates debugging from guessing. The next two lessons show the tests that lock fixes in.

Other ways pros do this

OptionWhat it isWhen pros pick itTrade-offs
Studio debuggerBreakpoints, Watch, Call Stack and stepping inside Studio.Most server and client bugs you can reproduce in a playtest.Pausing changes timing, so races can hide while paused.
print and warnText in Output, also visible in F9 on a live server.Quick traces and anything you cannot pause, such as a live server.Easy to forget in the code. Warnings can fail the playtest suite.
Error Report in the Creator HubErrors aggregated from live servers and clients.Bugs players hit that you never reproduced.Arrives after the fact and only shows the error, not the values.
Studio MCP and an AI assistantTools that start Play, run Luau and read Output for you.Repeating the same reproduce-and-read loop many times.It still needs your method; it will happily read the wrong log.

Put the debugging method in order.

  1. Test the guess with a breakpoint, logpoint or print
  2. Form one guess about the cause
  3. Decide whether it happens on the server or the client
  4. Reproduce the bug with the smallest steps
  5. Fix it and add a test that fails without the fix
Answer

1. Reproduce the bug with the smallest steps 2. Decide whether it happens on the server or the client 3. Form one guess about the cause 4. Test the guess with a breakpoint, logpoint or print 5. Fix it and add a test that fails without the fix. Reproduce, locate the side, guess, test the guess, then fix and lock the fix in with a test.

Open this step in lesson mode · Link to this step · This confused me

10Where the referee picture breaks

Where does it break?“The referee with the only real scoreboard” is a good picture of the server. Where does it stop being true?

It breaks here. The server is also the field itself, and it cannot see things that exist only on a client, such as a player's GUI or a LocalScript's effects.

The true model. The server runs the authoritative copy of the whole game world. Anything that matters (coins, damage, purchases) is decided there, and clients only see what it replicates to them.

The referee picture says the server sees everything that counts. That is true for coins and damage. It is false for the HUD: the label that says Coins 85 exists only on your client, so a server breakpoint can never show it, and a server log never mentions it.

The HUD shows the wrong objective text during Cooldown. Where should the breakpoint go?

  1. In src/client/Hud.luau, with the client view active, because the label only exists on the client
  2. In RoundService on the server, because the server owns the round
  3. In the command bar
  4. Anywhere; breakpoints pause both sides
Answer

In src/client/Hud.luau, with the client view active, because the label only exists on the client. The server publishes the phase, but Hud.luau on the client writes the text. A server breakpoint cannot see a client-only label.

Open this step in lesson mode · Link to this step · This confused me

11Challenges

Level 1, Apprentice

Challenge

Find the server log in the Developer Console and classify one line.

Start from
The game at milestone m06 (download)

Done means

  • During Play you open the Developer Console with F9
  • You switch between the client and server logs
  • You name one line that is an engine warning, not a Luau error

Hints

  1. F9 opens the console inside the running session. The Output panel is a different window.
  2. A Luau error names a script path and a line number. Look for a line without one.

Why is a logpoint better than a standard breakpoint on CoinService's Touched handler?

  1. Touched fires many times per step, and a logpoint records each one without pausing the server
  2. Logpoints run on the client
  3. Breakpoints do not work inside event handlers
  4. A logpoint fixes the bug automatically
Answer

Touched fires many times per step, and a logpoint records each one without pausing the server. Every body part that bumps the coin fires Touched. A logpoint writes each event to Output and keeps the game running.

Level 2, Builder

Challenge

Watch the coin distance check without freezing the game, then catch only the refused touches.

Start from
The game at milestone m06 (download)

Done means

  • A logpoint in CoinService prints the distance on every touch
  • A conditional breakpoint pauses only when the distance is over 12
  • Both are removed or disabled afterwards

Hints

  1. Right-click the gutter for Insert Logpoint and Insert Conditional Breakpoint.
  2. The distance expression is (rootPart.Position - coin.Position).Magnitude.
  3. Stand next to a pad, not on it, to trigger the reject path.

Level 3, Professional

Challenge

The learner file pays 0 up close and 10 far away. Use a breakpoint to see which branch runs, then fix it. Run it from the server during Play:

luau
game.ServerScriptService.RunGameTests:Invoke("debugging")
Start from
The game at milestone m04 (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("debugging") in the server command bar. Copy the pass code from Output.

Done means

  • challenges/debugging_branch.luau pays the coin value at 12 studs or closer
  • It pays 0 past 12 studs and never doubles
  • challenges/debugging.luau prints TEST PASS for all five cases

Hints

  1. Set a server breakpoint on the comparison in debugging_branch.luau and watch distance for 1 and for 20.
  2. The real rule in CoinService returns before paying when the magnitude is greater than 12.
  3. The close path pays coinValue once.
Solution
luau
function Branch.payout(distance: number, coinValue: number): number
	if distance > 12 then
		return 0
	end
	return coinValue
end

Open this step in lesson mode · Link to this step · This confused me

12Recap

Reference Debugger keys and windows

Breakpoints, Watch and Call Stack are in the Script tab and under Window, Debug2. debug.traceback is in the debug library6.

F10
Run the current line without entering functions.
F11
Enter the function on the current line.
Shift+F11
Finish the current function and pause in its caller.
F9 or /console
Logs, memory and network in a running session, including live servers.
debug.traceback(message?)
The call stack as a string, for when you cannot pause.

Recap

  1. A breakpoint pauses only the side that runs the line; server code means the green server view.
  2. Use logpoints and conditions on noisy events like Touched; read Watch and the Call Stack when paused.
  3. Debug with a method: reproduce, locate the side, guess, test the guess, then lock the fix in with a test.

The server is the referee with the only real scoreboard, until the server is also the field itself, and it cannot see things that exist only on a client, such as a player's GUI or a LocalScript's effects.

Next Unit tests with Jest-Lua

Open this step in lesson mode · Link to this step · This confused me