Instance.new
Summary
Constructors
new()
Instance.new(className: string, parent: Instance?)Creates a new
Instanceof the class supplied byclassName.
Parameters
className:string— the class to create.parent:Instance?— optional initial parent for the new instance.
Overview
Instance.new creates a new Instance of the class
passed as className. It accepts an optional second parent argument.
local part = Instance.new("Part")print(part) --> Partprint(part.ClassName) --> Partprint(part.Name) --> PartParenting
A new instance begins unparented unless you supply a parent. Configure it
before assigning 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 = truepart.Parent = workspaceInstance.new() also accepts the parent as an optional second argument:
local part = Instance.new("Part", Workspace)part.Name = "Platform"part.Size = Vector3.new(8, 1, 8)part.Position = Vector3.new(0, 10, 0)part.Anchored = trueIn Vortex Studio 0.3.4, assigning
Parentor passing this second argument is accepted, but script-created children are not reliably listed by a service’sGetChildrenorFindFirstChild. Do not rely on it to add runtime objects to the editor-authored Workspace hierarchy.
Default state
In Vortex Studio 0.3.4, a freshly created
Partis anchored, collidable, and casts shadows. It has the namePart, position and rotation(0, 0, 0), an identityCFrame, size(4, 1, 2), transparency0, and an approximately(0.64, 0.64, 0.64)color. Any property you do not set yourself holds the runtime default.
Testing Notes
These observations are from Vortex Studio 0.3.4 and may differ in later releases.
Instance.fromExistingis not exposed (nil) in either Script or LocalScript in 0.3.4.- Common creatable classes include
Part,Model,Folder,Script,LocalScript,ModuleScript,IntValue,StringValue,BindableEvent,RemoteEvent,RemoteFunction,PointLight, andSpotLight.SpawnLocation,Texture,Decal, andSurfaceAppearanceare not constructible in the tested runtime.