Skip to content

Workspace

The world: every part, model, character and terrain that exists physically lives here.

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

Only what’s inside the Workspace is simulated, drawn and touchable, and Scripts inside it run on the server.

Type: Dimension · Default: '3d' · Access: read-only · Replicates: yes

Whether the game is '3d' or '2d', from the game’s settings.

Type: number · Default: 196.2 · Range: 0 to 2,000 (clamped) · Access: read/write · Replicates: yes

Studs/s² downward.

It can change while the game runs, and characters’ jumps use it too.

Type: number · Default: -500 · Access: read/write · Replicates: yes

Unanchored parts below this are destroyed; characters below it die.

Use it to clean up things that fall off the world.

Type: Camera | null · Default: null · Access: read/write · Replicates: no

On a player’s device: that device’s Camera. Null on the server.

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

raycast(origin: Vector3, direction: Vector3, options: RaycastOptions = {}): RaycastResult | null

Casts a ray; returns the first part hit (and where), or null. direction’s length is the maximum distance.

Parts with canCollide off don’t stop rays. Characters do, unless options.hitCharacters is false. Returns null when nothing is hit, or when direction has no length. See RaycastOptions and RaycastResult.

getPartsInRadius(center: Vector3, radius: number): BasePart[]

Parts whose bounds overlap a sphere.

Only parts: characters and terrain aren’t included.

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 { Vector3, print, workspace } from '@rally/sdk';
const hit = workspace.raycast(new Vector3(0, 100, 0), new Vector3(0, -200, 0));
if (hit) print(`hit ${hit.instance.getFullName()} at height ${hit.position.y}`);
import { Vector3, workspace } from '@rally/sdk';
function explode(center: Vector3, radius: number) {
for (const part of workspace.getPartsInRadius(center, radius)) {
if (part.anchored) continue;
const away = part.position.sub(center).unit;
part.applyImpulse(away.mul(part.getMass() * 60));
}
}
explode(new Vector3(0, 2, 0), 12);