Roblox UtilitiesDevlHub Roblox Documentation

Data type

Instance

Holds the constructor for Instances.

The Instance data type holds constructors for Instance objects.

Constructors 2#

newReturns an Instance of the specified class.
fromExistingReturns an Instance which is a copy of an existing Instance.

new(className: string, parent: Instance?)#

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.

Luau
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)
NameTypeDefaultDescription
classNamestringClass name of the new instance to create.
parentInstance?Optional object to parent the new instance to. Not recommended for performance reasons (see description above).

fromExisting(existingInstance: 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.

NameTypeDefaultDescription
existingInstanceInstanceThe existing Instance to copy property values from.