Skip to content

DataModel

The root of the game tree, game: every service is a child of it.

  • Inherits: Instance
  • Creatable: No. It’s created with the game; use game (import { game } from '@rally/sdk').
  • Replication: Replicated: clients get a copy, and changes the server makes reach them.

There’s one game on the game server and one on each player’s device. The server’s is the truth: it replicates into the others. Reach the services through the named exports of @rally/sdk (workspace, Players, …), which are typed, or with game.getService.

Type: Role · Access: read-only

Where this code runs: 'server' on the game server, 'client' on a player’s device, or 'standalone' in Rally Studio’s Play, which runs the server’s and the client’s scripts together in your browser. See Game role.

Type: boolean · Access: read-only

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

Type: boolean · Access: read-only

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

Inherited from Instance: name, archivable, id, className, parent, destroyed

getService(name: string): Instance

Look up a service by class name, e.g. game.getService('Players').

Throws for an unknown name. The result is typed as Instance; the named exports are typed as the service.

getInstanceById(id: string): Instance | undefined

The instance in this game with this id, or undefined.

Inherited from Instance: getPropertyChangedSignal, setAttribute, getAttribute, getAttributes, getAttributeChangedSignal, getChildren, getDescendants, findFirstChild, findFirstChildOfClass, findFirstChildWhichIsA, findFirstAncestor, findFirstAncestorWhichIsA, waitForChild, isA, isDescendantOf, isAncestorOf, getFullName, clearAllChildren, destroy, clone, toString

Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged

import { game, print } from '@rally/sdk';
if (game.isServer) print('on the server');
if (game.isClient) print("on a player's device");
const players = game.getService('Players'); // the same object as the `Players` export
print(players.getFullName());