Skip to content

Instance.new

Summary

Syntax

Instance.new(className: string): Instance

Overview

Instance.new creates a new Instance of the class passed as className.

local part = Instance.new("Part")
print(part) --> Part
print(part.ClassName) --> Part
print(part.Name) --> Part

Parenting

A new instance has no parent: it exists in memory, but it is not rendered, replicated, or saved until you assign its Parent.

Set the parent last, after configuring the instance, so scripts listening for new objects receive it fully configured:

local part = Instance.new("Part")
part.Name = "Platform"
part.Size = Vector3.new(8, 1, 8)
part.Position = Vector3.new(0, 10, 0)
part.Anchored = true
part.Parent = workspace

Default state

A freshly created Part is unanchored, medium gray, and positioned at the world origin (0, 0.5, 0), with its Name defaulting to the class name. Any property you do not set yourself holds the class default.

Notes