Reference API Roblox

Engine API

Website

Related

Reference API Roblox

ScriptProfilerService

A service that captures sampling-based profiles of Luau script execution on the server or on a client.

This class is not creatable. Instances of this class cannot be created with Instance.new.
This class is a service. It is a singleton that may be acquired with GetService.
Tags: [NotCreatable, Service]

Member index 11

HistoryMember
620ClientRequestData(player: Player): null
620ClientStart(player: Player, frequency: int?): null
620ClientStop(player: Player): null
620DeserializeJSON(jsonString: string?): Dictionary
620SaveScriptProfilingData(jsonString: string, filename: string): string
620ServerRequestData(): null
620ServerStart(frequency: int?): null
620ServerStop(): null
620OnNewData(player: Player, jsonString: string)
inherited from Instance
731Archivable: bool
731Capabilities: SecurityCapabilities
731IsInSandbox: bool
731Name: string
731Parent: Instance
731PredictionMode: PredictionMode
731Sandboxed: bool
731UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
707GetDescendants(): Instances
486GetFullName(): string
706GetStyled(name: string, selector: string?): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
698QueryDescendants(selector: string): Instances
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
731children(): Instances
731clone(): Instance
731destroy(): null
731findFirstChild(name: string, recursive: bool = false): Instance
731getChildren(): Instances
731isDescendantOf(ancestor: Instance): bool
731remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
731childAdded(child: Instance)
inherited from Object
731ClassName: string
731className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
731isA(className: string): bool
647Changed(property: string)

Description

ScriptProfilerService provides a scripting interface to Roblox's Luau script profiler, which periodically samples running Luau threads to attribute CPU time to the functions that consume it.

Profiling is controlled independently for the server and for individual clients: ServerStart() and ServerStop() govern server-side scripts, while ClientStart() and ClientStop() govern a given player's client. Calling ServerRequestData() or ClientRequestData() collects a snapshot of the profiling results, which is delivered asynchronously through the OnNewData event as a JSON string. That string can be turned into a structured Luau table with DeserializeJSON().

This service powers the Script Profiler in the in-experience Developer Console.

History 16

Members 11

ClientRequestData

Parameters (1)
playerPlayer
Returns (1)
null

Requests a snapshot of the profiling data collected for the given player's client. The data is not returned directly; instead it is delivered asynchronously through the OnNewData event as a JSON string.

When called on the server this replicates a data request to the target client, and when called on the client it gathers the local player's profiling data directly. On a client the player argument must be the local player.

History 1

ClientStart

Parameters (2)
playerPlayer
frequencyint?
Returns (1)
null

Begins profiling the Luau scripts running on the given player's client. The profiler periodically samples running Luau threads at frequency samples per second; if frequency is omitted it defaults to 1000, and a value outside the range [1, 10000] raises an error.

When called on the server this replicates a request to the target client to start profiling, and when called on the client it starts sampling the local player's scripts directly. On a client the player argument must be the local player.

History 1

ClientStop

Parameters (1)
playerPlayer
Returns (1)
null

Stops profiling the Luau scripts running on the given player's client.

When called on the server this replicates a request to the target client to stop profiling, and when called on the client it stops sampling the local player's scripts directly. On a client the player argument must be the local player.

History 1

DeserializeJSON

Parameters (1)
jsonStringstring?
Returns (1)
Dictionary

Converts the raw JSON produced by the profiler into a Luau table so the results can be inspected programmatically rather than parsed by hand. The returned table mirrors the profiling session, exposing entries such as its version, session start and end times, categories, call nodes, and function metadata.

An empty or non-object input yields no data.

This function has a custom internal state. It may behave in a non-standard way.

History 1

Tags: [CustomLuaState]

OnNewData

Parameters (2)
playerPlayer
jsonStringstring

Fires when a new profiling snapshot becomes available, in response to ClientRequestData() or ServerRequestData(). The data is delivered as a JSON string in jsonString; pass it to DeserializeJSON() to obtain a structured table. player identifies the client the data came from, or is nil when the data was collected on the server.

History 1

SaveScriptProfilingData

Parameters (2)
jsonStringstring
filenamestring
Returns (1)
string

History 1

ServerRequestData

Parameters (0)
No parameters.
Returns (1)
null

Requests a snapshot of the profiling data collected on the server. The data is not returned directly; instead it is delivered asynchronously through the OnNewData event as a JSON string, with no associated player.

History 1

ServerStart

Parameters (1)
frequencyint?
Returns (1)
null

Begins profiling the Luau scripts running on the server. The profiler periodically samples running Luau threads at frequency samples per second; if frequency is omitted it defaults to 1000, and a value outside the range [1, 10000] raises an error.

History 1

ServerStop

Parameters (0)
No parameters.
Returns (1)
null

Stops profiling the Luau scripts running on the server.

History 1

Settings