Skip to content

RunService

Per-step events (heartbeat, stepped, renderStepped) and where the code is running.

  • Get it: import { RunService } from '@rally/sdk'

Each step of the game runs, in order: due task work, stepped, physics, then heartbeat. The game server steps 30 times a second (a step covers at most 0.25 seconds, however long the server was busy); players’ devices step once per frame. Each handler gets dt, the seconds since the previous step.

Changes the server makes in heartbeat replicate about 20 times a second. For purely visual motion, animate on players’ devices instead.

isServer(): boolean

True on the game server, and in Rally Studio’s Play.

isClient(): boolean

True on a player’s device, and in Rally Studio’s Play.

Arguments: dt: number

Every step, after physics (dt in seconds).

Arguments: dt: number

Every step, before physics.

Arguments: dt: number

Client: every frame, before rendering.

import { Part, RunService, Vector3, getChild, workspace } from '@rally/sdk';
const spinner = getChild(workspace, 'Spinner', Part);
RunService.heartbeat.connect((dt) => {
spinner.rotation = spinner.rotation.add(new Vector3(0, 90 * dt, 0)); // 90 degrees a second
});