We use cookies on this site to enhance your user experience

RunService

RunService

The RunService contains methods and events for time-management as well as for managing the context in which a game or script is running. Methods like IsClient, IsServer, IsStudio, can help you determine where Lua code is running. These methods are useful for ModuleScripts that could be required by both the client and server. In addition, you can use IsStudio to add special behavior for in-studio testing.

RunService also provides events that help you manage time. Stepped and Heartbeat can be used for game logic while RenderStepped can be used for visual effects. These events fire with “delta time” values. Stepped also includes the total amount of time passed in a game. Correctly using the change in time values for game logic is important for changing values over time. As a general rule, multiply your change in time by the rate of change to get the amount a value should change in one frame. For example:

-- Note: delta just means "change in/of"
speed = deltaPosition / deltaTime
deltaPosition = speed * deltaTime

Functions

Name Type Description
void

Given a string name of a function and a priority, this method binds the function to RunService/RenderStepped.

bool

Query if a script is running on a client

bool
bool

Query if the “Run” button was pressed in Studio

bool

Query if the game is currently running

bool

Query if a script is running on the server

bool

Query if a script is running within Roblox Studio

void

Pauses the physics and scripts in a place.

Run

void

Creates a waypoint and then runs the game just like the Play button does in studio.

void

Stops the running simulation.

void

Unbinds a function that was bound to the render loop using RunService/BindToRenderStep.

Inherited from Instance

ClearAllChildren Clone Destroy FindFirstAncestor FindFirstAncestorOfClass FindFirstAncestorWhichIsA FindFirstChild FindFirstChildOfClass FindFirstChildWhichIsA GetChildren GetDebugId GetDescendants GetFullName GetPropertyChangedSignal IsA IsAncestorOf IsDescendantOf WaitForChild

Events

Name Type Description

Fired on every frame in the RunService.

Fires every render frame (about 60 times per second).

Fired on every step in the RunService, a time of approximately 1/60th of a second.

Inherited from Instance

AncestryChanged Changed ChildAdded ChildRemoved DescendantAdded DescendantRemoving