ScriptDebuggerService
Provides programmatic breakpoint management, execution control, and runtime inspection of Luau scripts during a playtest.
| Memory category | Instances |
|---|
Member index 12
Description
ScriptDebuggerService exposes the Roblox Studio Luau debugger for
programmatic use. It provides functionality for breakpoint management,
execution control, and runtime state inspection.
APIs in this class are currently in beta and are subject to breaking changes.
Breakpoint Propagation
Breakpoints set in the edit DataModel are set on the specific script instance and do not propagate to clones, but they propagate to corresponding scripts in play data models at the start of a playtest. Breakpoints set in a play DataModel propagate to script clones in the same data model and to corresponding scripts in other data models.
Parallel Threads
The behavior of this API with parallel Luau is undefined.
History 13
- 721 Add OnStopped
- 721 Add Resumed
- 721 Add SetExceptionBreakMode
- 721 Add RemoveBreakpoint
- 721 Add Pause
- 721 Add GetVariables
- 721 Add GetThreads
- 721 Add GetStackTrace
- 721 Add GetRootVariables
- 721 Add Evaluate
- 721 Add ClearBreakpoints
- 721 Add AddBreakpoint
- 721 Add ScriptDebuggerService
Members 12
AddBreakpoint
| Parameters (2) | ||
|---|---|---|
| scriptInstance | LuaSourceContainer | |
| breakpoint | Dictionary | |
| Returns (1) | ||
| Dictionary | ||
Adds a breakpoint to the specified script. If a breakpoint already exists on the same script and line, its data is replaced with the new configuration.
Errors if the script instance or breakpoint argument is invalid.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
- 721 Add AddBreakpoint
ClearBreakpoints
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| null | ||
Removes all breakpoints across all scripts.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
- 721 Add ClearBreakpoints
Evaluate
| Parameters (2) | Default | |
|---|---|---|
| expression | string | |
| frameId | int? | nil |
| Returns (1) | ||
| Dictionary | ||
Evaluates a Luau expression in the context of the specified stack frame,
or globally if no frameId is provided.
Errors if the expression has a syntax error or frameId is invalid.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
GetRootVariables
| Parameters (1) | ||
|---|---|---|
| frameId | int | |
| Returns (1) | ||
| Array | ||
Returns the root variables (locals, upvalues, globals) for the specified
stack frame. Each variable includes a VariablesReference field; if
greater than 0, pass it to
GetVariables() to drill into
children.
Errors if frameId is invalid. Returns empty if the DataModel is
not stopped at a breakpoint or exception, or when stopped via
Pause().
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
- 721 Add GetRootVariables
GetStackTrace
| Parameters (2) | Default | |
|---|---|---|
| threadId | int | |
| startFrame | int? | nil |
| Returns (1) | ||
| Dictionary | ||
Returns the call stack for a paused thread, ordered innermost (current
execution point) to outermost. Use startFrame (1‑based) for paginated
retrieval of large stacks.
Errors if threadId or startFrame is invalid.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
- 721 Add GetStackTrace
GetThreads
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| Array | ||
Returns all paused Luau threads. Should be called when the DataModel is stopped (typically inside OnStopped). Returns empty results when the DataModel is not stopped at a breakpoint or exception, or when stopped via Pause().
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
- 721 Add GetThreads
GetVariables
| Parameters (1) | ||
|---|---|---|
| variablesReference | int | |
| Returns (1) | ||
| Array | ||
Drills into structured variables such as tables and
Instances. Pass a VariablesReference obtained from a
script variable returned by
GetRootVariables() or a
previous call to this method.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
- 721 Add GetVariables
OnStopped
| Parameters (1) | ||
|---|---|---|
| stopped | Dictionary | |
| Returns (1) | ||
| Dictionary | ||
The primary mechanism for reacting to debugger pauses. Set this to a
function that receives a stopped payload and returns a script resume
action dictionary indicating how execution should continue.
Only one OnStopped per DataModel is allowed; it is not inherited
from the edit DataModel.
If the callback returns nothing or throws, DebuggerResumeType.Resume is assumed. Avoid modifying the DataModel, throwing unhandled errors, or calling async yielding functions inside this callback.
Late-Set Behavior
If OnStopped is set while the DataModel is already stopped at a
breakpoint and the previous value was nil, the callback runs
immediately.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
Pause
| Parameters (0) | ||
|---|---|---|
| No parameters. | ||
| Returns (1) | ||
| null | ||
Requests the debugger to pause at the next safe point. This method is asynchronous and returns immediately. When the thread pauses, OnStopped fires with reason ScriptStoppedReason.Pause. Has no effect if already stopped.
Only meaningful when the DataModel is running during a playtest.
Calling Pause() while already stopped at a breakpoint has no effect.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
RemoveBreakpoint
| Parameters (2) | ||
|---|---|---|
| scriptInstance | LuaSourceContainer | |
| line | int | |
| Returns (1) | ||
| bool | ||
Removes the breakpoint at the specified line in the given script. Returns
false if no breakpoint exists on the line (no-op). Errors if the script
instance or line number is invalid.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
History 1
- 721 Add RemoveBreakpoint
Resumed
| Parameters (1) | |
|---|---|
| threadIds | Array |
Fires when a previously paused thread resumes. After this event, all
frameId values, VariablesReference values, and script variable objects
from that thread are invalidated. Re-fetch them the next time the
DataModel stops if needed.
Avoid modifying the DataModel, throwing unhandled errors, or calling async yielding functions inside this event handler.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |
SetExceptionBreakMode
| Parameters (1) | ||
|---|---|---|
| breakMode | DebugBreakModeType | |
| Returns (1) | ||
| null | ||
Sets the exception break mode on all DataModels. Use DebugBreakModeType to specify when the debugger should pause on exceptions.
| Security | PluginSecurity |
|---|---|
| Thread safety | Unsafe |