# RunService

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, Not replicated, Service
- Memory category: Instances
- HTML page: https://rapi.sleaze.dev/classes/RunService/
- Roblox documentation: https://create.roblox.com/docs/reference/engine/classes/RunService

Service responsible for all runtime activity and progression of time.

## Properties

### ClientGitHash

```luau
RunService.ClientGitHash: string
```

- Tags: Read only, Roblox script security, Read capabilities: Basic

### RunState

```luau
RunService.RunState: Enum.RunState
```

- Tags: Not replicated, Write: Plugin security, Read capabilities: Basic + PluginOrOpenCloud

The current run state of the game's simulation.

### FrameNumber

```luau
RunService.FrameNumber: number
```

- Tags: Read only, Read capabilities: Basic + InternalTest, Write capabilities: InternalTest

## Methods

### BindToAnimation

```luau
RunService:BindToAnimation(function: (...any) -> ...any, frequency: Enum.StepFrequency? = Enum.StepFrequency.Hz30, priority: number? = 2000): RBXScriptConnection
```

- Tags: Capabilities: Basic

Binds a custom function to be called at a fixed frequency before Animators update when fixed simulation is enabled, or immediately before [`BindToSimulation`](https://rapi.sleaze.dev/classes/RunService.md) callbacks otherwise.

Parameters:

- `function`: The function to call. This function will be passed one parameter called `deltaTime`, which shows the elapsed time since the callback's previous invocation.
- `frequency`: Optional `StepFrequency` value indicating the frequency at which to call the bound function. Defaults to `StepFrequency.Hz30`.
- `priority`: Optional priority of the binding as an integer; it determines the order in which bound functions are called within a simulation step. Lower numbers are called first. If two bindings have the same priority, the order between them is unspecified. Defaults to 2000.

Returns: A [`RBXScriptConnection`](https://rapi.sleaze.dev/index/types/RBXScriptConnection.md) that can be disconnected to unregister the callback.

### BindToRenderStep

```luau
RunService:BindToRenderStep(name: string, priority: number, function: (...any) -> ...any)
```

- Tags: Capabilities: Basic

Given a string name of a function and a priority, this method binds the function to [`RunService.PreRender`](https://rapi.sleaze.dev/classes/RunService.md).

Parameters:

- `name`: Label for the binding which can be used with `Unbind` if the binding is no longer needed.
- `priority`: Priority of the binding as an integer; it determines when during the render step to call the custom function. The lower this number, the sooner the custom function will be called. If two bindings have the same priority, the engine will randomly pick one to run first.
- `function`: The custom function being bound.

### BindToSimulation

```luau
RunService:BindToSimulation(function: (...any) -> ...any, frequency: Enum.StepFrequency? = Enum.StepFrequency.Hz30, priority: number? = 2000): RBXScriptConnection
```

- Tags: Capabilities: Basic

Binds a custom function to be called at a fixed frequency which is independent of the frame rate.

Parameters:

- `function`: The function to call. This function will be passed one parameter called `deltaTime` which shows how much time passed between the beginning of the previous simulation step and the beginning of the current simulation step.
- `frequency`: Optional `StepFrequency` value indicating the frequency at which to call the bound function. If not provided, the default frequency will be used.
- `priority`: Optional priority of the binding as an integer; it determines the order in which bound functions are called within a simulation step. Lower numbers are called first. If two bindings have the same priority, the order between them is unspecified. Defaults to 2000.

Returns: An [`RBXScriptConnection`](https://rapi.sleaze.dev/index/types/RBXScriptConnection.md) that can be disconnected to unbind the function from the simulation step.

### GetControlAndVariantRolloutFlags

```luau
RunService:GetControlAndVariantRolloutFlags(): ...any
```

- Tags: Roblox script security, Capabilities: Basic

### GetCoreScriptVersion

```luau
RunService:GetCoreScriptVersion(): string
```

- Tags: Roblox script security, Capabilities: Basic

### GetPhysicsStepId

```luau
RunService:GetPhysicsStepId(): number
```

- Tags: Roblox script security, Capabilities: Basic

### GetPredictionStatus

```luau
RunService:GetPredictionStatus(context: Instance): Enum.PredictionStatus
```

- Tags: Capabilities: Basic, Simulation access

Checks the `PredictionStatus` of a specific context instance, useful for debugging scripts affecting multiple instances where some might be predicted and others might not.

Parameters:

- `context`: The [`Instance`](https://rapi.sleaze.dev/classes/Instance.md) for which to check prediction status.

Returns: The `PredictionStatus` of the given instance, indicating whether it is predicted, authoritative, or not participating in prediction.

### GetRobloxClientChannel

```luau
RunService:GetRobloxClientChannel(): string
```

- Tags: Roblox script security, Capabilities: Basic

### GetRobloxClientIxpEnrolledExperiments

```luau
RunService:GetRobloxClientIxpEnrolledExperiments(): string
```

- Tags: Roblox script security, Capabilities: Basic

### GetRobloxGuiFocused

```luau
RunService:GetRobloxGuiFocused(): boolean
```

- Tags: Roblox script security, Capabilities: Basic

### GetRobloxVersion

```luau
RunService:GetRobloxVersion(): string
```

- Tags: Roblox script security, Capabilities: Basic

### GetTotalScriptPlusExecutionTime

```luau
RunService:GetTotalScriptPlusExecutionTime(): number
```

- Tags: Roblox script security, Capabilities: Basic

### IsClient

```luau
RunService:IsClient(): boolean
```

- Tags: Thread safe, Capabilities: Basic

Returns whether the current environment is running on the client.

Returns: Whether the current environment is running the client.

### IsEdit

```luau
RunService:IsEdit(): boolean
```

- Tags: Thread safe, Capabilities: Basic + PluginOrOpenCloud

Returns whether the current environment is in `Edit` mode.

Returns: Whether the current environment is in "edit" mode.

### IsResimulating

```luau
RunService:IsResimulating(): boolean
```

- Tags: Thread safe, Capabilities: Basic, Simulation access

Returns whether the client is currently in a resimulation step after a misprediction in the server authority model.

Returns: Whether the engine is currently resimulating.

### IsRunMode

```luau
RunService:IsRunMode(): boolean
```

- Tags: Thread safe, Capabilities: Basic

Returns whether a **Run** playtest has been initiated in Studio.

Returns: Whether a **Run** playtest has been initiated in Studio.

### IsRunning

```luau
RunService:IsRunning(): boolean
```

- Tags: Capabilities: Basic

Returns whether the experience is currently running.

Returns: Whether the experience is currently running.

### IsServer

```luau
RunService:IsServer(): boolean
```

- Tags: Thread safe, Capabilities: Basic

Returns whether the current environment is running on the server.

Returns: Whether the current environment is running on the server.

### IsStudio

```luau
RunService:IsStudio(): boolean
```

- Tags: Thread safe, Capabilities: Basic

Returns whether the current environment is running in Studio.

Returns: Whether the current environment is running in Studio.

### IsTeamCreateViewer

```luau
RunService:IsTeamCreateViewer(): boolean
```

- Tags: Roblox script security, Thread safe, Capabilities: Basic

### IsTeamTest

```luau
RunService:IsTeamTest(): boolean
```

- Tags: Roblox script security, Thread safe, Capabilities: Basic

### Pause

```luau
RunService:Pause()
```

- Tags: Plugin security, Capabilities: Basic

Pauses the experience's simulation if it is running, suspending physics and scripts.

### Run

```luau
RunService:Run()
```

- Tags: Plugin security, Capabilities: Basic

Runs the game's simulation, running physics and scripts.

### Set3dRenderingEnabled

```luau
RunService:Set3dRenderingEnabled(enable: boolean)
```

- Tags: Roblox script security, Capabilities: Basic

### SetPredictionMode

```luau
RunService:SetPredictionMode(context: Instance, mode: Enum.PredictionMode)
```

- Tags: Capabilities: Basic

Sets the prediction mode for an [`Instance`](https://rapi.sleaze.dev/classes/Instance.md) to an [`PredictionMode`](https://rapi.sleaze.dev/classes/Instance.md) value.

Parameters:

- `context`: The [`Instance`](https://rapi.sleaze.dev/classes/Instance.md) for which to set the prediction mode.
- `mode`: The [`PredictionMode`](https://rapi.sleaze.dev/classes/Instance.md) to set for the context instance.

### SetRobloxGuiFocused

```luau
RunService:SetRobloxGuiFocused(focus: boolean)
```

- Tags: Roblox script security, Capabilities: Basic

### Stop

```luau
RunService:Stop()
```

- Tags: Plugin security, Capabilities: Basic

Stops the experience's simulation if it is running.

### UnbindFromRenderStep

```luau
RunService:UnbindFromRenderStep(name: string)
```

- Tags: Capabilities: Basic

Unbinds a function that was bound to the render loop using [`RunService:BindToRenderStep()`](https://rapi.sleaze.dev/classes/RunService.md).

Parameters:

- `name`: The name of the function being unbound.

### getThrottleFramerateEnabled

```luau
RunService:getThrottleFramerateEnabled(): boolean
```

- Tags: Roblox script security, Capabilities: Basic

### setThrottleFramerateEnabled

```luau
RunService:setThrottleFramerateEnabled(enable: boolean)
```

- Tags: Roblox script security, Capabilities: Basic

### Reset

```luau
RunService:Reset()
```

- Tags: Deprecated, Plugin security, Capabilities: Basic

**Deprecated:** This item is deprecated and should not be used in new work.

Resets the current game to a waypoint set when [`RunService:Run()`](https://rapi.sleaze.dev/classes/RunService.md) was called.

## Events

### Heartbeat

```luau
RunService.Heartbeat: RBXScriptSignal<(deltaTime: number)>
```

- Tags: Capabilities: Basic

Fires every frame, after the physics simulation has completed.

### Misprediction

```luau
RunService.Misprediction: RBXScriptSignal<(time: number, instances: { any }, stats: { [string]: any })>
```

- Tags: Capabilities: Basic + PluginOrOpenCloud

In the server authority model, fires during prediction when the engine detects that the client has diverged from the server's authoritative state. Intended for plugin-based debugging.

### PostSimulation

```luau
RunService.PostSimulation: RBXScriptSignal<(deltaTimeSim: number)>
```

- Tags: Capabilities: Basic

Fires every frame, after the physics simulation has completed.

### PreAnimation

```luau
RunService.PreAnimation: RBXScriptSignal<(deltaTimeSim: number)>
```

- Tags: Capabilities: Basic

Fires every frame, prior to the physics simulation but after rendering.

### PreRender

```luau
RunService.PreRender: RBXScriptSignal<(deltaTimeRender: number)>
```

- Tags: Capabilities: Basic

Fires every frame, prior to the frame being rendered.

### PreSimulation

```luau
RunService.PreSimulation: RBXScriptSignal<(deltaTimeSim: number)>
```

- Tags: Capabilities: Basic

Fires every frame, prior to the physics simulation.

### RenderStepped

```luau
RunService.RenderStepped: RBXScriptSignal<(deltaTime: number)>
```

- Tags: Capabilities: Basic

Fires every frame, prior to the frame being rendered.

### RobloxGuiFocusedChanged

```luau
RunService.RobloxGuiFocusedChanged: RBXScriptSignal<(isRobloxGuiFocused: boolean)>
```

- Tags: Roblox script security, Capabilities: Basic

### Rollback

```luau
RunService.Rollback: RBXScriptSignal<(time: number)>
```

- Tags: Capabilities: Basic

In the server authority model, this fires after rolling back the predicted state due to a misprediction, but before resimulation begins.

### Stepped

```luau
RunService.Stepped: RBXScriptSignal<(time: number, deltaTime: number)>
```

- Tags: Capabilities: Basic

Fires every frame, prior to the physics simulation.

## 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`
