Skip to content

Instance

Supported Datatype

Holds the constructor for Instances.

Description

The Instance data type holds constructors for Instance objects.

Constructors

new Not yet Returns an Instance of the specified class.
Instance.new(className: string, parent: Instance?)

Returns an Instance of the specified class.

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)
fromExisting Not yet Returns an Instance which is a copy of an existing Instance.
Instance.fromExisting(existingInstance: Instance)

Returns an Instance which is a copy of an existing Instance.

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.

Roblox reference: Instance