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(), orInstance.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.
Properties
Section titled “Properties”primaryPart
Section titled “primaryPart”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
Methods
Section titled “Methods”parts(): BasePart[]Every BasePart inside the model, at any depth.
getBoundingBox
Section titled “getBoundingBox”getBoundingBox(): { center: Vector3; size: Vector3 }Center of all parts (min/max corners of their positions ± half sizes, ignoring rotation).
getPivot
Section titled “getPivot”getPivot(): Vector3The model’s pivot: primaryPart.position, or the center of the bounding box.
pivotTo
Section titled “pivotTo”pivotTo(position: Vector3): voidMoves every part so the pivot lands on position.
Parts keep their rotation.
translateBy
Section titled “translateBy”translateBy(offset: Vector3): voidMoves 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
Events
Section titled “Events”Inherited from Instance: changed, childAdded, childRemoved, descendantAdded, descendantRemoving, ancestryChanged, destroying, attributeChanged
Examples
Section titled “Examples”Spawn a copy of a model
Section titled “Spawn a copy of a model”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));