# ScriptProfilerService

Roblox Engine API class from Roblox Studio 0.744.0.7441077 (version-7aaa6838d36c4448).

- Inherits from, nearest first: [Instance](https://rapi.sleaze.dev/classes/Instance.md), [Object](https://rapi.sleaze.dev/classes/Object.md)
- Tags: Not creatable, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/ScriptProfilerService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/ScriptProfilerService

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

## Methods

### ClientRequestData

```luau
ScriptProfilerService:ClientRequestData(player: Player)
```

- Tags: Plugin security

Requests the current script profiling data from the specified player's client.

Parameters:

- `player`: The [`Player`](https://rapi.sleaze.dev/classes/Player.md) whose client should report its profiling data. When called on a client, this must be the local player.

### ClientStart

```luau
ScriptProfilerService:ClientStart(player: Player, frequency: number?)
```

- Tags: Plugin security

Begins Luau script profiling for the specified player's client.

Parameters:

- `player`: The [`Player`](https://rapi.sleaze.dev/classes/Player.md) whose client should start profiling. When called on a client, this must be the local player.
- `frequency`: Optional sampling frequency in samples per second. Defaults to `1000` and must be within the range `[1, 10000]`.

### ClientStop

```luau
ScriptProfilerService:ClientStop(player: Player)
```

- Tags: Plugin security

Stops Luau script profiling for the specified player's client.

Parameters:

- `player`: The [`Player`](https://rapi.sleaze.dev/classes/Player.md) whose client should stop profiling. When called on a client, this must be the local player.

### DeserializeJSON

```luau
ScriptProfilerService:DeserializeJSON(jsonString: string?): { [string]: any }
```

- Tags: Custom Lua state, Plugin security

Parses a script-profiling JSON string into a structured Luau table.

Parameters:

- `jsonString`: The profiling data encoded as a JSON string, such as the value delivered by [`OnNewData`](https://rapi.sleaze.dev/classes/ScriptProfilerService.md).

Returns: A dictionary representing the parsed profiling data, including the session's categories, call nodes, and function metadata.

### SaveScriptProfilingData

```luau
ScriptProfilerService:SaveScriptProfilingData(jsonString: string, filename: string): string
```

- Tags: Roblox script security

### ServerRequestData

```luau
ScriptProfilerService:ServerRequestData()
```

- Tags: Plugin security

Requests the current script profiling data from the server.

### ServerStart

```luau
ScriptProfilerService:ServerStart(frequency: number?)
```

- Tags: Plugin security

Begins Luau script profiling on the server.

Parameters:

- `frequency`: Optional sampling frequency in samples per second. Defaults to `1000` and must be within the range `[1, 10000]`.

### ServerStop

```luau
ScriptProfilerService:ServerStop()
```

- Tags: Plugin security

Stops Luau script profiling on the server.

## Events

### OnNewData

```luau
ScriptProfilerService.OnNewData: RBXScriptSignal<(player: Player, jsonString: string)>
```

- Tags: Plugin security

Fires when a new profiling data snapshot becomes available after a data request.

### RequestData

```luau
ScriptProfilerService.RequestData: RBXScriptSignal<()>
```

- Tags: Hidden, Roblox engine security

### SetProfilingState

```luau
ScriptProfilerService.SetProfilingState: RBXScriptSignal<(start: boolean, frequency: number)>
```

- Tags: Hidden, Roblox engine security

## Inherited members

- From [Instance](https://rapi.sleaze.dev/classes/Instance.md): `Archivable`, `archivable`, `Attributes`, `AttributesReplicate`, `AttributesSerialize`, `HistoryId`, `Name`, `Parent`, `PredictionMode`, `PropertyStatusStudio`, `RobloxLocked`, `SerializedOverrides`, `SourceAssetId`, `Tags`, `UniqueId`, `numExpectedDirectChildren`, `DataCost`, `Capabilities`, `DefinesCapabilities`, `IsInSandbox`, `Sandboxed`, `AddTag`, `ClearAllChildren`, `Clone`, `Destroy`, `FindFirstAncestor`, `FindFirstAncestorOfClass`, `FindFirstAncestorWhichIsA`, `FindFirstChild`, `FindFirstChildOfClass`, `FindFirstChildWhichIsA`, `FindFirstDescendant`, `GetActor`, `GetAttribute`, `GetAttributeChangedSignal`, `GetAttributes`, `GetChildren`, `GetDebugId`, `GetDescendants`, `GetFullName`, `GetStyled`, `GetStyledPropertyChangedSignal`, `GetTags`, `HasTag`, `IsAncestorOf`, `IsDescendantOf`, `IsPropertyModified`, `QueryDescendants`, `RemoveTag`, `ResetPropertyToDefault`, `SetAttribute`, `WaitForChild`, `Remove`, `children`, `clone`, `destroy`, `findFirstChild`, `getChildren`, `isDescendantOf`, `remove`, `AncestryChanged`, `AttributeChanged`, `ChildAdded`, `ChildRemoved`, `DescendantAdded`, `DescendantRemoving`, `Destroying`, `StyledPropertiesChanged`, `childAdded`
- From [Object](https://rapi.sleaze.dev/classes/Object.md): `ClassName`, `className`, `GetPropertyChangedSignal`, `IsA`, `isA`, `Changed`
