Skip to content

Model

Groups parts that belong together, such as a car or a house, so you can move them as one.

  • Inherits: Instance
  • Creatable: Yes: new Model(), or Instance.new('Model', parent).
  • Replication: Replicated: clients get a copy, and changes the server makes reach them.

A Model is a container: the parts inside it are still separate physics bodies. To make unanchored parts move together, join them with WeldConstraints. To move a whole model, call pivotTo or translateBy, which move every part inside it (at any depth) without rotating them.

Type: BasePart | null · Default: null · Access: read/write · Replicates: yes

The part whose position is the model’s pivot. When it’s null, the pivot is the center of the model’s bounding box.

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

parts(): BasePart[]

Every BasePart inside the model, at any depth.

getBoundingBox(): { center: Vector3; size: Vector3 }

Center of all parts (min/max corners of their positions ± half sizes, ignoring rotation).

getPivot(): Vector3

The model’s pivot: primaryPart.position, or the center of the bounding box.

pivotTo(position: Vector3): void

Moves every part so the pivot lands on position.

Parts keep their rotation.

translateBy(offset: Vector3): void

Moves every part inside the model by offset.

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 { Model, ServerStorage, Vector3, getChild, workspace } from '@rally/sdk';
const template = getChild(ServerStorage, 'Car', Model);
const car = template.clone();
car.parent = workspace;
car.pivotTo(new Vector3(0, 3, 40));