RunService¶
Service responsible for all runtime activity and progression of time.
Description¶
RunService contains methods and events for time management as well as for
managing the context in which an experience or script is running. Methods like
IsClient(),
IsServer(), and
IsStudio() can help you determine under what
context code is running. These methods are useful for
ModuleScripts that may be required by both client and
server scripts. Furthermore, IsStudio() can be
used to add special behaviors for in‑Studio testing.
RunService also houses events that allow your code to adhere to the engine's
frame‑by‑frame loop, such as PreRender,
PreAnimation,
PreSimulation,
PostSimulation, and
Heartbeat. Selecting the proper event to use for
any case is important, so you should read
Task Scheduler
to make an informed decision.
Context Test Results¶
| Environment | Class.RunService:IsStudio()|IsStudio |
Class.RunService:IsClient()|IsClient |
Class.RunService:IsServer()|IsServer |
Class.RunService:IsEdit()|IsEdit |
Class.RunService:IsRunning()|IsRunning |
Class.RunService:IsRunMode()|IsRunMode |
|---|---|---|---|---|---|---|
| Live (Client) | false |
true |
false |
true |
false |
|
| Live (Server) | false |
false |
true |
true |
false |
|
| Edit | true |
true |
true |
true |
false |
false |
| Collaborative Edit | true |
true |
false |
true |
false |
false |
| Run Mode | true |
false |
true |
true |
true |
|
| Play Mode (Client) | true |
true |
false |
true |
false |
|
| Play Mode (Server) | true |
false |
true |
true |
false |
|
| Team Test (Client) | true |
true |
false |
true |
false |
|
| Team Test (Server) | true |
false |
true |
true |
false |
|
| Luau Execution | false |
false |
true |
false |
false |
Inheritance¶
Object → Instance → RunService
Nova inheritance: Instance → RunService
Methods¶
BindToRenderStep Supported Function Given a string name of a function and a priority, this method binds the function to RunService.PreRender.
Given a string name of a function and a priority, this method binds the function to RunService.PreRender.
The BindToRenderStep() function binds a custom function to be called at
a specific time during the render step. There are three main arguments:
name, priority, and what function to call.
As it is linked to the client's rendering process, BindToRenderStep()
can only be called on the client.
Name¶
The name parameter is a label for the binding and can be used with
RunService.UnbindFromRenderStep() if the binding is no longer
needed.
local RunService = game:GetService("RunService")
local function functionToBind() end
-- Bind the function above to the binding named "tempBinding"
RunService:BindToRenderStep("tempBinding", 1, functionToBind)
-- Unbind the function bound to "tempBinding"
RunService:UnbindFromRenderStep("tempBinding")
Priority¶
The priority of the binding is 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. The default
control scripts run with these specific priorities:
- Player Input:
100 - Camera Controls:
200For convenience; the RenderPriority enum can be used to determine the integer value to set a binding. For example, to make a binding right before the default camera update, simply subtract1from the camera priority level.
When using RenderPriority, remember to use .Value at the end of
the desired enum. RunService.BindToRenderStep() will not work if
just the enum is used on its own.
local RunService = game:GetService("RunService")
local function beforeCamera(delta)
-- Code in here will run before the default camera script
end
RunService:BindToRenderStep("Before camera", Enum.RenderPriority.Camera.Value - 1, beforeCamera)
Custom Function and Delta Time¶
The last argument (function) is the custom function to call. This
function will be passed one parameter called deltaTime which shows how
much time passed between the beginning of the previous render step and the
beginning of the current render step.
All rendering updates will wait until the code in the render step
finishes. Make sure that any code called by BindToRenderStep() runs
quickly and efficiently; if code takes too long, the experience visuals
will be choppy.
Roblox reference signature
IsClient Supported Function Returns whether the current environment is running on the client.
Returns whether the current environment is running on the client.
If the code that invoked this method is running in a client context (in a
LocalScript, in a ModuleScript required by a
LocalScript, or in a Script with
RunContext set to RunContext.Client),
this method will return true. In all other cases, this method will
return false.
If this method returns true, the current environment can access
client‑only features like RunService.PreRender or
Players.LocalPlayer.
IsRunMode Supported Function Returns whether a Run playtest has been initiated in Studio.
This method returns whether a Run playtest has been initiated in
Studio. It will continue to return true if the simulation has been
paused using the Pause button; however, once it has been stopped using
the Stop button, it will revert to returning false. Note that Studio
only enters "run" mode when a Run playtest (without the user's player
character) is initiated. Also note that this method will return false if
the simulation was started using RunService.Run().
IsRunning Supported Function Returns whether the experience is currently running.
Returns whether the experience is currently running. IsRunning() will
always return the inverse of IsEdit() except
when the simulation has been paused, in which case both methods will
return false.
RobloxScriptSecurityIsServer Supported Function Returns whether the current environment is running on the server.
This method returns whether the current environment is running on the
server. If the code that invoked this method is running in a server
context (in a Script with RunContext
set to RunContext.Server or RunContext.Legacy, or in a
ModuleScript required by a Script), this method will
return true. In all other cases, this method will return false.
If this function returns true, then the current environment can access server‑only features like ServerStorage or ServerScriptService.
IsStudio Supported Function Returns whether the current environment is running in Studio.
This method returns whether the current environment is running in Studio. It can be used to wrap code that should only execute when testing in Studio.
Pause Supported Function Pauses the experience's simulation if it is running, suspending physics and scripts.
This method pauses the experience's simulation if it is running,
suspending physics and scripts. When the simulation is paused,
IsRunning() will return false.
PluginSecurityReset Supported Function Deprecated Resets the current game to a waypoint set when RunService.Run() was called.
Resets the current game to a waypoint set when RunService.Run() was called.
The Reset function resets the current game to a waypoint set when Run was called. This method should only be used after Run was called.
PluginSecurityRun Supported Function Runs the game's simulation, running physics and scripts.
Runs the game's simulation, running physics and scripts.
This method runs the experience's simulation (physics and scripts). When
the simulation is running, IsRunning() will
return true. However, IsRunMode() will
only return true if the simulation was started using the Run button
in Studio.
PluginSecurityStop Supported Function Stops the experience's simulation if it is running.
This method stops the experience's simulation if it is running. When the
simulation is stopped, IsRunning() will
return false and IsEdit() will return
true.
In contrast to the Stop button in Studio, calling this method will not restore the experience to the state it was in prior to the simulation being run. This means any changes made to the experience by the physics simulation and scripts will persist after the simulation has ended.
PluginSecurityUnbindFromRenderStep Supported Function Unbinds a function that was bound to the render loop using RunService.BindToRenderStep().
Unbinds a function that was bound to the render loop using RunService.BindToRenderStep().
Given a name of a function sent to BindToRenderStep(), this method will unbind the function from being called during PreRender. This is used to unbind bound functions once they are no longer needed, or when they no longer need to fire every step.
If there is no bound function by the given name, this method takes no action and continues without raising an error.
Events¶
Heartbeat Supported Event Fires every frame, after the physics simulation has completed.
The Heartbeat event fires every frame, after the physics simulation has
completed. The deltaTime argument indicates the time that has elapsed
since the previous frame.
This event is when most scripts run. It occurs at the end of each frame
and it's also when any waiting scripts are executed, such as those
scheduled with the task library. Heartbeat is commonly used
for periodic tasks, such as updating core game systems like health
regeneration.
Following this step, the engine sends property updates and events to the server or clients which are later received as part of the replication receive step.
RenderStepped Supported Event Fires every frame, prior to the frame being rendered.
Stepped Supported Event Fires every frame, prior to the physics simulation.
Fires every frame, prior to the physics simulation.
Migration Note¶
This event has been superseded by PreSimulation which should be used for new work.
Inherited members¶
Inherited from Instance: 8 properties, 36 methods, 7 events. They are documented on the base class page.
28 modern Roblox member(s) are not implemented yet — expand to inspect
Members declared by Roblox's RunService class (or by a missing base class) that Nova does not expose. Use this list to scope a migration; the compatibility guide has the recommended workaround.
Properties¶
| Member | Signature | Status | Notes | Flags |
|---|---|---|---|---|
ClientGitHash |
ClientGitHash: string |
Not yet | — | ReadOnly, NotReplicated, RobloxScriptSecurity |
FrameNumber |
FrameNumber: int64 |
Not yet | — | ReadOnly, NotReplicated |
RunState |
RunState: RunState |
Not yet | The current run state of the game's simulation. | NotReplicated, PluginSecurity |
Methods¶
| Member | Signature | Status | Notes | Flags |
|---|---|---|---|---|
BindToAnimation |
RunService:BindToAnimation(function: Function, frequency: StepFrequency = Hz30, priority: int = 2000): RBXScriptConnection |
Not yet | Binds a custom function to be called at a fixed frequency before Animators update when fixed simulation is enabled, or immediately before BindToSimulation callbacks ot… |
— |
BindToSimulation |
RunService:BindToSimulation(function: Function, frequency: StepFrequency = Hz30, priority: int = 2000): RBXScriptConnection |
Not yet | Binds a custom function to be called at a fixed frequency which is independent of the frame rate. | — |
GetControlAndVariantRolloutFlags |
RunService:GetControlAndVariantRolloutFlags(): Tuple |
Not yet | — | RobloxScriptSecurity |
GetCoreScriptVersion |
RunService:GetCoreScriptVersion(): string |
Not yet | — | RobloxScriptSecurity |
GetPhysicsStepId |
RunService:GetPhysicsStepId(): int64 |
Not yet | — | RobloxScriptSecurity |
GetPredictionStatus |
RunService:GetPredictionStatus(context: Instance): PredictionStatus |
Not yet | Checks the PredictionStatus of a specific context instance, useful for debugging scripts affecting multiple instances where some might be… | — |
GetRobloxClientChannel |
RunService:GetRobloxClientChannel(): string |
Not yet | — | RobloxScriptSecurity |
GetRobloxGuiFocused |
RunService:GetRobloxGuiFocused(): bool |
Not yet | — | RobloxScriptSecurity |
GetRobloxVersion |
RunService:GetRobloxVersion(): string |
Not yet | — | RobloxScriptSecurity |
getThrottleFramerateEnabled |
RunService:getThrottleFramerateEnabled(): bool |
Not yet | — | RobloxScriptSecurity |
GetTotalScriptPlusExecutionTime |
RunService:GetTotalScriptPlusExecutionTime(): double |
Not yet | — | RobloxScriptSecurity |
IsEdit |
RunService:IsEdit(): bool |
Not yet | Returns whether the current environment is in Edit mode. |
PluginSecurity |
IsResimulating |
RunService:IsResimulating(): bool |
Not yet | Returns whether the client is currently in a resimulation step after a misprediction in the server authority model. | — |
IsTeamTest |
RunService:IsTeamTest(): bool |
Not yet | — | RobloxScriptSecurity |
Set3dRenderingEnabled |
RunService:Set3dRenderingEnabled(enable: bool): null |
Not yet | — | RobloxScriptSecurity |
SetPredictionMode |
RunService:SetPredictionMode(context: Instance, mode: PredictionMode): null |
Not yet | Sets the prediction mode for an Instance to an PredictionMode value. | — |
SetRobloxGuiFocused |
RunService:SetRobloxGuiFocused(focus: bool): null |
Not yet | — | RobloxScriptSecurity |
setThrottleFramerateEnabled |
RunService:setThrottleFramerateEnabled(enable: bool): null |
Not yet | — | RobloxScriptSecurity |
Events¶
| Member | Signature | Status | Notes | Flags |
|---|---|---|---|---|
Misprediction |
Misprediction(time: double, instances: Array, stats: Dictionary) |
Not yet | 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-ba… | — |
PostSimulation |
PostSimulation(deltaTimeSim: double) |
Not yet | Fires every frame, after the physics simulation has completed. | — |
PreAnimation |
PreAnimation(deltaTimeSim: double) |
Not yet | Fires every frame, prior to the physics simulation but after rendering. | — |
PreRender |
PreRender(deltaTimeRender: double) |
Not yet | Fires every frame, prior to the frame being rendered. | — |
PreSimulation |
PreSimulation(deltaTimeSim: double) |
Not yet | Fires every frame, prior to the physics simulation. | — |
RobloxGuiFocusedChanged |
RobloxGuiFocusedChanged(isRobloxGuiFocused: bool) |
Not yet | — | RobloxScriptSecurity |
Rollback |
Rollback(time: double) |
Not yet | In the server authority model, this fires after rolling back the predicted state due to a misprediction, but before resimulation begins. | — |
Roblox reference: RunService
Generated from Nova's API dump and Roblox creator-docs. Nova-only members come from the engine's reflection metadata.