Skip to content

Service · inherits Instance

ScriptProfilerService

Official docs ↗

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

About ScriptProfilerService

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.

Methods 7

  • ClientRequestData(player: Player) → ()PluginRequests the current script profiling data from the specified player's client.

    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.

  • ClientStart(player: Player, frequency: int?) → ()PluginBegins Luau script profiling for the specified player's client.

    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.

  • ClientStop(player: Player) → ()PluginStops Luau script profiling for the specified player's client.

    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.

  • DeserializeJSON(jsonString: string?) → DictionaryPluginParses a script-profiling JSON string into a structured Luau table.

    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.

  • ServerRequestData() → ()PluginRequests the current script profiling data from the server.

    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.

  • ServerStart(frequency: int?) → ()PluginBegins Luau script profiling on the server.

    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.

  • ServerStop() → ()PluginStops Luau script profiling on the server.

    Stops profiling the Luau scripts running on the server.

Events 1

  • OnNewDataScriptProfilerService.OnNewData:Connect(function(player, jsonString))PluginFires when a new profiling data snapshot becomes available after a data request.

    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.

ScriptProfilerService 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.