Instance

Show Deprecated

The Instance data type holds constructors for Instance objects.

Summary

Constructors

Constructors

new

Creates a new Instance of type className. Abstract classes and services cannot be created with this constructor.

Note that when the Parent of an object is set, Luau listens to a variety of different property changes for replication, rendering, and physics. For performance reasons, it's recommended to set the instance's Parent property last when creating new objects, instead of specifying the second argument (parent) of this constructor.


local Workspace = game:GetService("Workspace")
-- Set new instance's parent last (recommended)
local part = Instance.new("Part")
part.Position = Vector3.new(0, 10, 0)
part.Parent = Workspace
-- Set new instance's parent in constructor (discouraged)
local part = Instance.new("Part", Workspace)
part.Position = Vector3.new(0, 10, 0)

Parameters

className: string

Class name of the new instance to create.

parent: Instance

Optional object to parent the new instance to. Not recommended for performance reasons (see description above).

fromExisting

Creates a new object with the same type and property values as an existing object. In most cases using Instance:Clone() is more appropriate, but this constructor is useful when implementing low‑level libraries or systems.

There are two behavioral differences between this constructor and the Instance:Clone() method:

  • This constructor will not copy any of the descendant Instances parented to the existing object.

  • This constructor will return a new object even if the existing object had Instance.Archivable set to false.

Parameters

existingInstance: Instance

The existing Instance to copy property values from.