PcoWSkbVqDnWTu_dm2ix

5 min

Breakpoints are checkpoints that pause or “break” the execution of your scripts at specific lines. You can use the pauses to inspect and debug your experience, watch variables, and inspect the call stack. Breakpoints are one of the most effective ways to debug functions, and therefore one of the most important debugging tools.

You can configure breakpoints to break only if certain conditions are met, to print a message to the Output window, and to run only on the client or server. You can also mix these configurations together to best suit your debugging needs.

Standard Breakpoints

Standard breakpoints pause your scripts when you playtest. To insert a standard breakpoint at a line of code, click the margin to the right of its line number. The breakpoint appears as a red dot.

Breakpoint Steps

If you insert a breakpoint at a line in a script, the script pauses before it executes that line. A yellow arrow called the “debugger” indicates which line of code executes next.

When the script pauses, you can monitor how your experience changes as the current line executes. You can also execute the following code one line at a time by stepping through them with the buttons in the Script Menu tab. The following table summarizes the three ways to step through code.

To remove the debugger and continue executing your code, click Resume in the Script Menu tab.

Button Action Description
Step Into The Step Into button moves the debugger into the code of the function on the current line. If there is no function on the current line, the debugger moves to the next line.
Step Over The Step Over button moves the debugger to the next line of code, not moving into functions.
Step Out The Step Out button moves the debugger out of the current function and to the next line of code after the function call. If the current line isn't inside a function, the debugger moves to the next line.

Advanced Breakpoints

Besides standard breakpoints, Studio has three other types of breakpoints: Logpoints, Conditional Breakpoints, and Contextual Breakpoints.

Logpoints

Logpoints are breakpoints that log messages to the Output window without pausing your scripts. This is useful for debugging variable values. Logpoints print the values for the variables before the line executes.

Logpoints can be more efficient for debugging variables than print() statements because they allow you to log messages to the Output window without having to stop or restart the active play session. They can help you keep your code clean while debugging and are easier to remove when you finish debugging.

You can convert existing breakpoints to be Logpoints by editing them to enable Continue Execution and have Log Messages.

Conditional Breakpoints

Conditional Breakpoints are breakpoints that pause your script only if a condition is true. This is useful when you want to debug how your functions execute only if certain variables have certain values.

You can convert existing breakpoints to be Conditional Breakpoints by editing them to disable Continue Execution and have Conditions.

Contextual Breakpoints

Standard breakpoints pause both the client and server. If you want to create a breakpoint that pauses on only the client or server, you can create Contextual Breakpoints while testing your experience. This is useful for debugging a ModuleScript that you reuse in both LocalScripts and Scripts.

Contextual Breakpoints are available only while testing. For more information on different testing modes, see Testing Modes.

Using Breakpoints

You can insert, edit, disable, and delete standard breakpoints, Conditional Breakpoints, Contextual Breakpoints, and Logpoints by following similar steps.

The icon for each breakpoint indicates its type:

  • A red circle indicates a standard Breakpoint.
  • A red circle with an equal sign indicates a Conditional Breakpoint.
  • A red diamond indicates a Logpoint.
  • A yellow circle indicates a Contextual Breakpoint.

Inserting Breakpoints

You can insert a breakpoint at any line of executable code.

To insert a standard breakpoint at a line of code, left-click the margin to the right of its line number. You can also right-click the margin and click Insert Breakpoint. The breakpoint appears as a red dot.

To insert a Conditional Breakpoint or Logpoint at a line:

  1. Right-click the margin to the right of the line number.
  2. Click Insert Conditional Breakpoint… or Insert Logpoint… to display the Edit Breakpoint pop-up.
  3. Define the Condition if applicable.
  4. Define the Log Message if applicable.
  5. Click Save.

To insert a Contextual Breakpoint at a line, you must first insert and delete a standard breakpoint:

  1. Left-click the margin to the right of the line number to insert a standard breakpoint. Left-click the breakpoint to delete it.
  2. Right-click the margin to the right of the line number to open the insertion menu.
  3. Click Insert Contextual Breakpoint.

Contextual Breakpoints are available only while testing. If you don’t see the option to insert a Contextual Breakpoint, insert a standard breakpoint, then check that your script has a blue client symbol or green server symbol.

Client
Server

Editing Breakpoints

Breakpoints have three options: Condition, Log Message, and Continue Execution.

The Condition is the expression that determines whether the breakpoint activates. The Condition is optional. If the Condition is empty, the breakpoint always activates. For example, if you want the breakpoint to activate only if the variable n equals 42, then define the Condition to be n == 42.

The Log Message is the expression that prints to the Output window when the condition is true. The Log Message is the same as what you would put as the argument for a print() statement. For example, you can define the Log Message to be "The value of n:", n to print the same message as print("The value of n:", n).

The Continue Execution option determines whether the breakpoint pauses the script if it activates. This option is enabled by default for Logpoints but disabled for other types of breakpoints.

To edit the options for a breakpoint:

  1. Right-click the breakpoint.
  2. Click Edit Breakpoint to open the Edit Breakpoint pop-up.
  3. Adjust the options for the breakpoint to meet your debugging needs.

To disable or enable a breakpoint, toggle the Enabled checkbox in the Edit Breakpoint pop-up. You can also right-click the breakpoint icon and click Disable Breakpoint or Enable Breakpoint.

To delete a breakpoint, left-click its icon. You can also right-click its icon and click Delete Breakpoint.

Using the Breakpoints Window

The Breakpoints window has buttons to enable, disable, and delete some or all breakpoints.

To open the Breakpoints window:

  1. Click the View tab at the top of Studio.
  2. Click Breakpoints.

You can enable and disable breakpoints by clicking the checkbox in the Enabled column.

Button Action
Delete the selected breakpoint.
Delete all breakpoints.
Disable all breakpoints. If all breakpoints are disabled, enable them all.
Go to the source code for the selected breakpoint.
Tags:
  • debugging
  • bugs
  • help