Model

Inherits from: PVInstanceInstance

A container for grouping multiple Parts (and other Models) into one logical object - a character, a car, a building - that can be positioned, moved, and scaled as a single unit via the pivot it inherits from PVInstance, without having to move every part inside it by hand.

Code Snippet

local car = Instance.new("Model")
car.Name = "Car"
car.Parent = workspace

local body = Instance.new("Part")
body.Name = "Body"
body.Size = Vector3.new(6, 2, 10)
body.Parent = car

car.PrimaryPart = body

-- Moves every part inside car together, preserving how they're arranged
-- relative to each other.
car:PivotTo(CFrame.new(0, 5, 0))

print(car:GetScale()) -- 1
car:ScaleTo(2) -- doubles the size of every part inside

Properties

NameTypeDescription
PrimaryPartBasePart?The part treated as the Model's main reference point by MoveTo() and by :SetPrimaryPartCFrame()-style code. PivotTo()/GetPivot() (inherited from PVInstance) are the modern replacement and don't require a PrimaryPart to be set at all.

Inherited from Instance

NameTypeDescription
ClassNamestringRead-only string naming the class this Instance belongs to.
NamestringA non-unique identifier of the Instance, used for organization and for accessing it in code. Maximum of 100 characters.
ParentInstanceThe hierarchical parent of the Instance. Setting this to nil removes the Instance from the DataModel tree unless something else still references it.
ArchivablebooleanWhether the Instance is included when the experience is published or saved, or when Clone() is called.
UniqueIdUniqueIdA read-only identifier for the Instance, distinct from Name, which is not guaranteed to be unique.

Methods

NameParametersReturnsDescription
MoveTo(position: Vector3):voidposition: Vector3voidMoves the whole Model so its lowest point sits at the given position - handy for dropping something onto the ground without knowing its exact height.
TranslateBy(delta: Vector3):voiddelta: Vector3voidShifts every part in the Model by the same offset, preserving their current rotations and relative arrangement.
ScaleTo(scale: number):voidscale: numbervoidResizes every part and joint in the Model by the given scale factor, relative to its current scale (see GetScale).
GetScale():numberVoidnumberReturns the Model's current overall scale factor, starting at 1 for an unscaled Model.

Inherited from PVInstance

NameParametersReturnsDescription
GetPivot():CFrameVoidCFrameReturns the object's current pivot - the BasePart's own CFrame, or a Model's designated pivot CFrame.
PivotTo(targetCFrame: CFrame):voidtargetCFrame: CFramevoidMoves the object so its pivot matches targetCFrame. On a Model, every part inside moves together, preserving their relative arrangement - this is the modern, correct way to reposition a Model (prefer it over setting PrimaryPart's CFrame).
GetBoundingBox():CFrame,Vector3VoidCFrame, Vector3Returns a CFrame and a Size describing the smallest axis-aligned box that contains every BasePart within the object.

Inherited from Instance

NameParametersReturnsDescription
FindFirstChild(name: string,recursive: boolean?):Instance?name: string, recursive: boolean?Instance?Returns the first child of the Instance with the given name, or nil if no such child exists. Searches descendants too if recursive is true.
FindFirstChildOfClass(className: string):Instance?className: stringInstance?Returns the first child of the Instance whose ClassName equals the given className, or nil if none exists.
FindFirstChildWhichIsA(className: string,recursive: boolean?):Instance?className: string, recursive: boolean?Instance?Returns the first child whose class matches or inherits from className (unlike FindFirstChildOfClass, which requires an exact match), or nil if none exists.
FindFirstAncestor(name: string):Instance?name: stringInstance?Returns the first ancestor of the Instance whose Name equals the given name, or nil if none exists.
FindFirstAncestorOfClass(className: string):Instance?className: stringInstance?Returns the first ancestor of the Instance whose ClassName equals the given className, or nil if none exists.
WaitForChild(childName: string,timeOut: number?):Instance?childName: string, timeOut: number?Instance?Yields the current thread until a child with the given name exists, then returns it. If timeOut is given and exceeded, returns nil instead of continuing to wait.
GetChildren():{Instance}Void{Instance}Returns an array containing all of the Instance's direct children.
GetDescendants():{Instance}Void{Instance}Returns an array containing all of the Instance's descendants.
IsDescendantOf(ancestor: Instance):booleanancestor: InstancebooleanReturns true if the Instance is a descendant of the given ancestor.
IsAncestorOf(descendant: Instance):booleandescendant: InstancebooleanReturns true if the Instance is an ancestor of the given descendant.
GetFullName():stringVoidstringReturns a string describing the Instance's ancestry, formed by concatenating Names with periods.
Clone():Instance?VoidInstance?Creates a copy of the Instance and all of its descendants, ignoring any that are not Archivable. Returns nil if the Instance itself is not Archivable.
Destroy():voidVoidvoidSets Parent to nil, locks the Parent property, disconnects all connections, and calls Destroy() on all children.
IsA(className: string):booleanclassName: stringbooleanReturns true if the Instance's class matches or inherits from the given class.
SetAttribute(attribute: string,value: Variant):voidattribute: string, value: VariantvoidSets the attribute with the given name to the given value.
GetAttribute(attribute: string):Variantattribute: stringVariantReturns the value assigned to the given attribute name, or nil if not set.
GetAttributes():{[string]: Variant}Void{[string]: Variant}Returns a dictionary of every attribute set on the Instance, keyed by attribute name.
GetAttributeChangedSignal(attribute: string):RBXScriptSignalattribute: stringRBXScriptSignalReturns an event that fires whenever the given attribute's value changes.
GetPropertyChangedSignal(property: string):RBXScriptSignalproperty: stringRBXScriptSignalReturns an event that fires whenever the given property changes, useful for properties (like Position on a BasePart) that don't have their own dedicated event.

Constructors

Inherited from Instance

NameDescription
new(className: string,parent: Instance?):InstanceCreates a new Instance of the given class name. Abstract classes and services cannot be created with this constructor. Setting parent in the constructor is discouraged for performance reasons - prefer setting the Parent property last, after all other properties are set.

Events

Inherited from Instance

NameParametersDescription
Changed(property: string)property: stringFires whenever any property of the Instance changes, passing the name of the property that changed.
ChildAdded(child: Instance)child: InstanceFires when a new child is directly parented to the Instance.
ChildRemoved(child: Instance)child: InstanceFires when a direct child is removed (its Parent set to something else or nil).
DescendantAdded(descendant: Instance)descendant: InstanceFires when any descendant (a child, or a child's child, and so on) is added anywhere below the Instance.
DescendantRemoving(descendant: Instance)descendant: InstanceFires right before any descendant is about to be removed from the hierarchy below the Instance.
AncestryChanged(child: Instance,parent: Instance)child: Instance, parent: InstanceFires when the Parent property of the Instance, or any of its ancestors, changes.
AttributeChanged(attribute: string)attribute: stringFires whenever any attribute on the Instance changes, passing the attribute's name.
Destroying()VoidFires immediately before the Instance is destroyed by Destroy(), while it (and its descendants) can still be read one last time.