Skip to content

Service · inherits Instance

ScriptDebuggerService

Official docs ↗

Provides programmatic breakpoint management, execution control, and runtime inspection of Luau scripts during a playtest.

About ScriptDebuggerService

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.

Methods 10

  • AddBreakpoint(scriptInstance: LuaSourceContainer, breakpoint: Dictionary) → ScriptBreakpointResultPluginAdds a breakpoint to a script. If a breakpoint already exists on the same script and line, its data is replaced.

    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.

  • ClearBreakpoints() → ()PluginRemoves all breakpoints across all scripts.
  • Evaluate(expression: string, frameId: int? = nil) → ScriptEvaluateResultPluginEvaluates a Luau expression in a stack frame's context.

    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.

  • GetRootVariables(frameId: int) → List<ScriptVariable>PluginReturns the root variables (locals, upvalues, globals) for a stack frame.

    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().

  • GetStackTrace(threadId: int, startFrame: int? = nil) → DebugStackTraceResultPluginReturns the call stack for a paused thread.

    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.

  • GetThreads() → List<ScriptDebugThread>PluginReturns all paused Luau threads.

    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().

  • GetVariables(variablesReference: int) → List<ScriptVariable>PluginDrills into structured variables (tables, Instances).

    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.

  • Pause() → ()PluginRequests the debugger to pause at the next safe point.

    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.

  • RemoveBreakpoint(scriptInstance: LuaSourceContainer, line: int) → booleanPluginRemoves the breakpoint on the given script and line.

    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.

  • SetExceptionBreakMode(breakMode: DebugBreakModeType) → ()PluginControls when the debugger pauses on exceptions.

    Sets the exception break mode on all DataModels. Use DebugBreakModeType to specify when the debugger should pause on exceptions.

Events 1

  • ResumedScriptDebuggerService.Resumed:Connect(function(threadIds))PluginFires when a previously paused thread resumes execution.

    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.

Callbacks 1

  • OnStopped(stopped: Dictionary) → ScriptResumeActionPluginThe primary callback for reacting to debugger pauses. Returns a resume action.

ScriptDebuggerService also has every member of Instance. Deprecated and Roblox-only members are hidden.

Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.