13 min read

Source: Roblox Creator Hub · CC BY 4.0 · View source · Code samples: MIT Imported 2026-10-03. Formatting adapted for this site.

ScriptDebuggerService

Inherits from: Instance → Object

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.

Inherits from: Instance

Memory category: Instances

Tags: NotCreatable, Service, NotReplicated

Methods

NameType / ReturnsDescription
ScriptDebuggerService:AddBreakpointScriptBreakpointResultAdds a breakpoint to a script. If a breakpoint already exists on the same script and line, its data is replaced.
ScriptDebuggerService:ClearBreakpoints()Removes all breakpoints across all scripts.
ScriptDebuggerService:EvaluateScriptEvaluateResultEvaluates a Luau expression in a stack frame's context.
ScriptDebuggerService:GetRootVariablesListReturns the root variables (locals, upvalues, globals) for a stack frame.
ScriptDebuggerService:GetStackTraceDebugStackTraceResultReturns the call stack for a paused thread.
ScriptDebuggerService:GetThreadsListReturns all paused Luau threads.
ScriptDebuggerService:GetVariablesListDrills into structured variables (tables, Instances).
ScriptDebuggerService:Pause()Requests the debugger to pause at the next safe point.
ScriptDebuggerService:RemoveBreakpointbooleanRemoves the breakpoint on the given script and line.
ScriptDebuggerService:SetExceptionBreakMode()Controls when the debugger pauses on exceptions.

Inherited from Instance

NameType / ReturnsDescription
Instance:AddTag()Applies a tag to the instance.
Instance:childrenInstancesReturns an array of the object's children.
Instance:ClearAllChildren()This method destroys all of an instance's children.
Instance:CloneInstanceCreate a copy of an instance and all its descendants, ignoring instances that are not Archivable.
Instance:cloneInstance
Instance:Destroy()Sets the Instance.Parent property to nil, locks the Instance.Parent property, disconnects all connections, and calls Destroy() on all children.
Instance:destroy()
Instance:FindFirstAncestorInstance?Returns the first ancestor of the Instance whose Instance.Name is equal to the given name.
Instance:FindFirstAncestorOfClassInstance?Returns the first ancestor of the Instance whose Object.ClassName is equal to the given className.
Instance:FindFirstAncestorWhichIsAInstance?Returns the first ancestor of the Instance for whom Object:IsA() returns true for the given className.
Instance:FindFirstChildInstance?Returns the first child of the Instance found with the given name.
Instance:findFirstChildInstance
Instance:FindFirstChildOfClassInstance?Returns the first child of the Instance whose ClassName is equal to the given class name.
Instance:FindFirstChildWhichIsAInstance?Returns the first child of the Instance for whom Object:IsA() returns true for the given className.
Instance:FindFirstDescendantInstance?Returns the first descendant found with the given Instance.Name.
Instance:GetActorActor?Returns the Actor associated with the Instance, if any.
Instance:GetAttributeVariantReturns the value which has been assigned to the given attribute name.
Instance:GetAttributeChangedSignalRBXScriptSignalReturns an event that fires when the given attribute changes.
Instance:GetAttributesDictionaryReturns a dictionary of the instance's attributes.
Instance:GetChildrenInstancesReturns an array containing all of the instance's children.
Instance:getChildrenInstances
Instance:GetDebugIdstringReturns a coded string of the debug ID used internally by Roblox.
Instance:GetDescendantsInstancesReturns an array containing all of the descendants of the instance.
Instance:GetFullNamestringReturns a string describing the instance's ancestry.
Instance:GetStyledVariantReturns the styled or explicitly modified value of the specified property, or else the default property value if it hasn't been styled/modified.
Instance:GetStyledPropertyChangedSignalRBXScriptSignalReturns an event that fires when the given style property changes on the instance.
Instance:GetTagsArrayGets an array of all tags applied to the instance.
Instance:HasTagbooleanCheck whether the instance has a given tag.
Instance:IsAncestorOfbooleanReturns true if an Instance is an ancestor of the given descendant.
Instance:IsDescendantOfbooleanReturns true if an Instance is a descendant of the given ancestor.
Instance:isDescendantOfboolean
Instance:IsPropertyModifiedbooleanReturns true if the value stored in the specified property is not equal to the code-instantiated default.
Instance:QueryDescendantsInstancesReturns an array containing all descendants of the instance that match the selector string.
Instance:Remove()Sets the object's Parent to nil, and does the same for all its descendants.
Instance:remove()
Instance:RemoveTag()Removes a tag from the instance.
Instance:ResetPropertyToDefault()Resets a property to its default value.
Instance:SetAttribute()Sets the attribute with the given name to the given value.
Instance:WaitForChildInstanceReturns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does.

Inherited from Object

NameType / ReturnsDescription
Object:GetPropertyChangedSignalRBXScriptSignalGet an event that fires when a given property of the object changes.
Object:IsAbooleanReturns true if an object's class matches or inherits from a given class.
Object:isAboolean

ScriptDebuggerService:AddBreakpoint

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.

Parameters

NameTypeDefaultDescription
scriptInstanceLuaSourceContainerThe LuaSourceContainer to place the breakpoint on.
breakpointDictionaryDictionary describing the breakpoint configuration through the following key-value pairs: - Line — Required 1-based line number. - Enabled — Optional boolean whether the breakpoint is active. Default is true. - Condition — Optional string indicating the Luau expression which must be truthy to pause, for example "health < 10". - LogMessage — Optional string message logged when the breakpoint is hit. This string is parsed as a comma-separated list of Luau expressions, evaluated in the breakpoint's scope, and concatenated LuaGlobals.print()‑style with spaces between segments. String literals are quoted; bare identifiers reference live values. For example, "'count is', count" produces output like count is 7. - ContinueExecution — If true, the DataModel does not pause when the breakpoint is hit. Default is false.

Returns

TypeDescription
ScriptBreakpointResultDictionary indicating whether the breakpoint was placed successfully and on which line. Includes the following key-value pairs: - Verified — Boolean value indicating whether the breakpoint was placed successfully. - Line — The line number the breakpoint was placed on. - Message — Optional explanation if Verified is false.
FieldValue
securityPluginSecurity
thread safetyUnsafe

ScriptDebuggerService:ClearBreakpoints

Removes all breakpoints across all scripts.

Returns

TypeDescription
()
FieldValue
securityPluginSecurity
thread safetyUnsafe

ScriptDebuggerService:Evaluate

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.

Parameters

NameTypeDefaultDescription
expressionstringThe Luau expression to evaluate.
frameIdint?nilOptional frame identifier. If omitted, evaluates globally.

Returns

TypeDescription
ScriptEvaluateResultDictionary with the following key-value pairs: - Result — String representation of the evaluated result. - Type — String indicating the Luau type of the result ("number", "string", "table", "Instance", etc.). - VariablesReference — If greater than 0, drill into with GetVariables().
FieldValue
securityPluginSecurity
thread safetyUnsafe

ScriptDebuggerService:GetRootVariables

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

Parameters

NameTypeDefaultDescription
frameIdintThe frame identifier from a debug stack frame Id field (see GetStackTrace()).

Returns

TypeDescription
ListAn array of script variable dictionaries, each containing the following key-value pairs: - Name — String value indicating the variable name or table key. - Value — String representation of the value. - Type — String indicating the Luau type ("number", "string", "table", "Instance", etc.). - Scope — ScriptVariableScope value (children inherit parent's scope). - VariablesReference — If greater than 0, call GetVariables() with this to get children.
FieldValue
securityPluginSecurity
thread safetyUnsafe

ScriptDebuggerService:GetStackTrace

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.

Parameters

NameTypeDefaultDescription
threadIdintThe thread identifier from a script debug thread Id field (see GetThreads()).
startFrameint?nilOptional 1-based frame index for paginated retrieval.

Returns

TypeDescription
DebugStackTraceResultDictionary containing the frames ordered innermost (current) to outermost. Contains the following key-value pairs: - Frames — Array of debug stack frame dictionaries. Each dictionary item contains the following key-value pairs: - Id — Numerical frame identifier; use with GetRootVariables() and Evaluate(). - Name — Human-readable name of the function at this frame. - ScriptPath — Full instance path of the script, for example "ServerScriptService.MainScript". - Line — 1-based line number where execution is paused at this frame. - TotalFrames — Total frame count, provided when paginating.
FieldValue
securityPluginSecurity
thread safetyUnsafe

ScriptDebuggerService:GetThreads

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

Returns

TypeDescription
ListAn array of script debug thread dictionaries, each containing the following key-value pairs: - Id — Numerical thread identifier; use with GetStackTrace() and stepping. - Name — Human-readable name of the script.
FieldValue
securityPluginSecurity
thread safetyUnsafe

ScriptDebuggerService:GetVariables

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.

Parameters

NameTypeDefaultDescription
variablesReferenceintA reference from a previous script variable's VariablesReference field (see GetRootVariables()).

Returns

TypeDescription
ListAn array of script variable dictionaries representing the children in the same format as variable dictionaries from GetRootVariables(). Returns empty if the DataModel is not stopped at a breakpoint or exception, or when stopped via Pause().
FieldValue
securityPluginSecurity
thread safetyUnsafe

ScriptDebuggerService:Pause

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.

Returns

TypeDescription
()
FieldValue
securityPluginSecurity
thread safetyUnsafe

ScriptDebuggerService:RemoveBreakpoint

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.

Parameters

NameTypeDefaultDescription
scriptInstanceLuaSourceContainerThe LuaSourceContainer containing the breakpoint.
lineintThe 1-based line number of the breakpoint to remove.

Returns

TypeDescription
booleantrue if a breakpoint was removed, false if no breakpoint existed on the line.
FieldValue
securityPluginSecurity
thread safetyUnsafe

ScriptDebuggerService:SetExceptionBreakMode

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

Parameters

NameTypeDefaultDescription
breakModeDebugBreakModeTypeThe DebugBreakModeType to set.

Returns

TypeDescription
()
FieldValue
securityPluginSecurity
thread safetyUnsafe

Events

NameType / ReturnsDescription
ScriptDebuggerService.ResumedFires when a previously paused thread resumes execution.

Inherited from Instance

NameType / ReturnsDescription
Instance.AncestryChangedFires when the Instance.Parent property of this object or one of its ancestors is changed.
Instance.AttributeChangedFires whenever an attribute is changed on the Instance.
Instance.ChildAddedFires after an object is parented to this Instance.
Instance.childAdded
Instance.ChildRemovedFires after a child is removed from this Instance.
Instance.DescendantAddedFires after a descendant is added to the Instance.
Instance.DescendantRemovingFires immediately before a descendant of the Instance is removed.
Instance.DestroyingFires immediately before (or is deferred until after) the instance is destroyed via Instance:Destroy().
Instance.StyledPropertiesChangedFires whenever any style property is changed on the instance, including when a property is set to nil.

Inherited from Object

NameType / ReturnsDescription
Object.ChangedFires immediately after a property of the object changes, with some limitations.

ScriptDebuggerService.Resumed

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.

Parameters

NameTypeDefaultDescription
threadIdsArrayAn array of thread identifiers that resumed.
FieldValue
securityPluginSecurity

Callbacks

NameType / ReturnsDescription
ScriptDebuggerService.OnStoppedScriptResumeActionThe primary callback for reacting to debugger pauses. Returns a resume action.

ScriptDebuggerService.OnStopped

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.

Parameters

NameTypeDefaultDescription
stoppedDictionaryDictionary describing why the debugger paused. The following key-value pairs are valid: - Reason — ScriptStoppedReason why the debugger paused. - ThreadIds — Array of thread identifiers that stopped. - ExceptionText — Error message present when Reason is ScriptStoppedReason.Exception.

Returns

TypeDescription
ScriptResumeActionDictionary specifying how to resume execution. Contains the following key-value pairs: - steppedType — DebuggerResumeType describing how to resume. - threadId — Number indicating which thread to step. Required for step actions.
FieldValue
securityPluginSecurity
thread safetyUnsafe

Properties

Inherited from Instance

NameType / ReturnsDescription
Instance.ArchivablebooleanDetermines if an Instance and its descendants can be cloned using Instance:Clone(), and can be saved/published.
Instance.archivableboolean
Instance.CapabilitiesSecurityCapabilitiesThe set of capabilities allowed to be used for scripts inside this container.
Instance.IsInSandboxbooleanIndicates whether the instance is inside a sandboxed container.
Instance.NamestringA non-unique identifier of the Instance.
Instance.ParentInstanceDetermines the hierarchical parent of the Instance.
Instance.PredictionModePredictionModeReflects the client-side prediction mode applied to the instance under server-authoritative physics.
Instance.RobloxLockedbooleanA deprecated property that used to protect CoreGui objects.
Instance.SandboxedbooleanWhen enabled, the instance can only access abilities in its Capabilities list.
Instance.UniqueIdUniqueIdA unique identifier for the instance.

Inherited from Object

NameType / ReturnsDescription
Object.ClassNamestringA read-only string representing the class this Object belongs to.
Object.classNamestring