new
Constructs a Roblox Instance or a library object. Not C++ heap allocation — there is no delete.
Syntax
Section titled “Syntax”auto child = new Class(parent);auto janitor = new Janitor();Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
Class | identifier | Instance class or lib type (Janitor). |
parent | Instance? | First argument becomes .Parent on Instances. |
Return value
Section titled “Return value”The constructed object.
Luau emit
Section titled “Luau emit”Instance.new("Class") / Class.new()
Description
Section titled “Description”Instances (Folder, IntValue, Part, …): emit Instance.new("Class"). The first argument is assigned to .Parent.
Libraries (Janitor and similar): emit Janitor.new().
Datatypes (Vector3, CFrame, UDim2, Color3): do not use new. Call them as values: Vector3(8, 1, 8).
Example
Section titled “Example”auto coins = new IntValue(leaderstats);auto janitor = new Janitor();part.Size = Vector3(8, 1, 8);Emits:
local coins: IntValue = Instance.new("IntValue")coins.Parent = leaderstatslocal janitor = Janitor.new()part.Size = Vector3.new(8, 1, 8)