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) --> Partprint(part.ClassName) --> Partprint(part.Name) --> PartParenting
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 = truepart.Parent = workspaceDefault state
A freshly created
Partis unanchored, medium gray, and positioned at the world origin (0, 0.5, 0), with itsNamedefaulting to the class name. Any property you do not set yourself holds the class default.
Notes
- Common creatable classes include
Part,Model,Folder,SpawnLocation,Script,LocalScript,ModuleScript,IntValue,StringValue,BindableEvent,RemoteEvent,RemoteFunction,PointLight, andSpotLight.