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.
Properties
Section titled “Properties”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.
isServer
Section titled “isServer”Type: boolean · Access: read-only
True on the game server, and in Rally Studio’s Play.
isClient
Section titled “isClient”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
Methods
Section titled “Methods”getService
Section titled “getService”getService(name: string): InstanceLook 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
Section titled “getInstanceById”getInstanceById(id: string): Instance | undefinedThe 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
Events
Section titled “Events”Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged
Examples
Section titled “Examples”Where am I running?
Section titled “Where am I running?”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` exportprint(players.getFullName());