Instance
The base class for instances in a place.
- Not creatable
- Created by the engine or used as a base class.
- Replication
- Standard
Behavior
Instance defines the properties, hierarchy methods, and events shared by
instances. It is abstract. Use Instance.new with a creatable class name.
Summary
Whether the instance is included when cloning or saving the hierarchy.
The concrete class name, such as "Part".
The instance name.
The parent instance, or nil when unparented.
Adds the named component and returns its ComponentHandle.
Adds the tag to this instance.
Destroys all children and their descendants.
Removes every tag from the instance.
Returns an unparented copy of the instance and its archivable descendants.
Removes the instance and its descendants from the hierarchy and disconnects their event connections.
Returns the nearest ancestor with the specified name, or nil if none exists.
Returns the nearest ancestor whose class exactly matches the specified class, or nil.
Returns the nearest ancestor that matches the class or one of its subclasses, or nil.
Returns the first child with the specified name, or nil if no child matches.
Returns the first direct child whose class exactly matches the specified class, or nil.
Returns the first child matching the class or one of its subclasses.
Returns the first descendant with the specified name, or nil if none exists.
Returns the named attribute, or nil if it is unset.
Returns a signal that fires when the named attribute changes.
Returns a table containing this instance's attribute names and values.
Returns an array of immediate children.
Returns a ComponentHandle when the instance has the component, or nil when it does not.
GetComponentChangedSignal(component: Component | string, field: string?): AstScriptSignal<string>serial onlyReturns the signal for changes to this instance's component.
Returns the component definitions attached to this instance.
Returns a diagnostic identifier for the instance.
Returns an array of all descendants.
Returns the dot-separated hierarchy path, such as Workspace.Model.Part.
Returns a signal that fires when the named property changes.
Returns Instances whose reference fields point to this instance.
Returns the tags assigned to this instance.
Returns whether the instance has the specified component.
Returns whether this instance has the specified tag.
Returns whether the instance belongs to the specified class or a subclass.
Returns whether the specified Instance is below this instance in the hierarchy.
Returns whether this instance is a descendant of the specified instance.
Removes the component and returns whether it was present.
Removes the tag from this instance.
Sets the named attribute.
Yields until a child with the specified name exists.
Fires when the instance or one of its ancestors is reparented.
Fires when an attribute changes.
Fires when a property changes.
Fires when an immediate child is added.
Fires when an immediate child is removed, including by Destroy.
Fires when an Instance becomes a descendant of this instance.
Fires before an Instance stops being a descendant of this instance.
Fires when the instance is being destroyed.
Properties
Archivable
Instance.Archivable: booleanWhether the instance is included when cloning or saving the hierarchy.
ClassName
Instance.ClassName: stringThe concrete class name, such as "Part". Use IsA to test whether an instance belongs to a class or one of its subclasses.
Name
Instance.Name: stringThe instance name. Sibling names do not have to be unique. FindFirstChild returns the first matching child.
Parent
Instance.Parent: Instance?The parent instance, or nil when unparented. Setting this property moves the instance in the hierarchy. An unparented instance remains accessible through existing script references.
Configure a new instance before parenting it so other scripts do not observe partially configured state.
Methods
AddComponent
Instance:AddComponent(component: Component | string, values: { [string]: any }?): ComponentHandleAdds the named component and returns its ComponentHandle. Omitted fields use schema defaults. Initial values are validated before they are applied. Required components are added with it. Adding a component requires serial execution.
AddTag
Instance:AddTag(tag: string): ()Adds the tag to this instance. Adding an existing tag does not create a duplicate.
ClearAllChildren
Instance:ClearAllChildren(): ()Destroys all children and their descendants. This instance remains in the hierarchy.
ClearTags
Instance:ClearTags(): ()Removes every tag from the instance.
Clone
Instance:Clone(): InstanceReturns an unparented copy of the instance and its archivable descendants. Returns nil if this instance has Archivable set to false.
Destroy
Instance:Destroy(): ()Removes the instance and its descendants from the hierarchy and disconnects their event connections. Setting Parent to nil alone does not disconnect events.
FindFirstAncestor
Instance:FindFirstAncestor(name: string): Instance?Returns the nearest ancestor with the specified name, or nil if none exists.
FindFirstAncestorOfClass
Instance:FindFirstAncestorOfClass(className: string): Instance?Returns the nearest ancestor whose class exactly matches the specified class, or nil.
FindFirstAncestorWhichIsA
Instance:FindFirstAncestorWhichIsA(className: string): Instance?Returns the nearest ancestor that matches the class or one of its subclasses, or nil.
FindFirstChild
Instance:FindFirstChild(name: string, recursive: boolean?): Instance?Returns the first child with the specified name, or nil if no child matches. Pass true as the second argument to search descendants recursively. Check the result before indexing it.
FindFirstChildOfClass
Instance:FindFirstChildOfClass(className: string): Instance?Returns the first direct child whose class exactly matches the specified class, or nil.
FindFirstChildWhichIsA
Instance:FindFirstChildWhichIsA(className: string, recursive: boolean?): Instance?Returns the first child matching the class or one of its subclasses. Set recursive to search descendants. Returns nil if no match exists.
FindFirstDescendant
Instance:FindFirstDescendant(name: string): Instance?Returns the first descendant with the specified name, or nil if none exists.
GetAttribute
Instance:GetAttribute(attribute: string): AttributeValue?Returns the named attribute, or nil if it is unset.
GetAttributeChangedSignal
Instance:GetAttributeChangedSignal(string): AstScriptSignalReturns a signal that fires when the named attribute changes.
GetAttributes
Instance:GetAttributes(): tableReturns a table containing this instance's attribute names and values.
GetChildren
Instance:GetChildren(): tableReturns an array of immediate children. The array is a snapshot and has no guaranteed order.
GetComponent
Instance:GetComponent(component: Component | string): ComponentHandle?Returns a ComponentHandle when the instance has the component, or nil when it does not.
GetComponentChangedSignal
Instance:GetComponentChangedSignal(component: Component | string, field: string?): AstScriptSignal<string>Returns the signal for changes to this instance's component. Supply a field name to observe that field. Without a field, the signal reports the changed field's name.
GetComponents
Instance:GetComponents(): tableReturns the component definitions attached to this instance.
GetDebugId
Instance:GetDebugId(number?): stringReturns a diagnostic identifier for the instance.
GetDescendants
Instance:GetDescendants(): tableReturns an array of all descendants. This traverses the subtree. Avoid repeatedly scanning large hierarchies when a cached result or hierarchy events can track changes.
GetFullName
Instance:GetFullName(): stringReturns the dot-separated hierarchy path, such as Workspace.Model.Part. Each call traverses the ancestors.
GetPropertyChangedSignal
Instance:GetPropertyChangedSignal(string): AstScriptSignalReturns a signal that fires when the named property changes.
GetReferencing
Instance:GetReferencing(component: Component | string, field: string?): { Instance }Returns Instances whose reference fields point to this instance. The component selects the schema; an optional field restricts the search to one reference field.
GetTags
Instance:GetTags(): tableReturns the tags assigned to this instance.
HasComponent
Instance:HasComponent(component: Component | string): booleanReturns whether the instance has the specified component. Accepts a Component definition or a component name.
HasTag
Instance:HasTag(string): booleanReturns whether this instance has the specified tag.
IsA
Instance:IsA(wanted: string): booleanReturns whether the instance belongs to the specified class or a subclass. A Part returns true for both IsA("Part") and IsA("BasePart").
IsAncestorOf
Instance:IsAncestorOf(descendant: Instance): booleanReturns whether the specified Instance is below this instance in the hierarchy.
IsDescendantOf
Instance:IsDescendantOf(ancestor: Instance): booleanReturns whether this instance is a descendant of the specified instance.
RemoveComponent
Instance:RemoveComponent(component: Component | string): booleanRemoves the component and returns whether it was present. Fails if another attached component requires it. Removing a component requires serial execution.
RemoveTag
Instance:RemoveTag(tag: string): ()Removes the tag from this instance.
SetAttribute
Instance:SetAttribute(attribute: string, value: AttributeValue?): ()Sets the named attribute. Passing nil removes it.
WaitForChild
Instance:WaitForChild(childName: string, timeOut: number?): InstanceYields until a child with the specified name exists. Use this when a client must wait for a replicated child. An optional timeout is measured in seconds. Without a timeout, a missing child can leave the thread waiting indefinitely.
Events
AncestryChanged
Instance.AncestryChanged: RBXScriptSignalFires when the instance or one of its ancestors is reparented.
AttributeChanged
Instance.AttributeChanged: RBXScriptSignalFires when an attribute changes. The argument is the attribute's name.
Changed
Instance.Changed: RBXScriptSignalFires when a property changes. The event arguments depend on the class; ValueBase classes report the stored value.
ChildAdded
Instance.ChildAdded: RBXScriptSignalFires when an immediate child is added. Passes the child instance. To track existing and future children, connect this event before calling GetChildren. Setup handlers should tolerate duplicate processing.
ChildRemoved
Instance.ChildRemoved: RBXScriptSignalFires when an immediate child is removed, including by Destroy. Passes the removed child.
DescendantAdded
Instance.DescendantAdded: RBXScriptSignalFires when an Instance becomes a descendant of this instance.
DescendantRemoving
Instance.DescendantRemoving: RBXScriptSignalFires before an Instance stops being a descendant of this instance.
Destroying
Instance.Destroying: RBXScriptSignalFires when the instance is being destroyed.
Example
local folder = Instance.new("Folder")
folder.Name = "Markers"
folder.Parent = workspace
print(folder:GetFullName())Subclasses
Accoutrement · Animation · AnimationController · AnimationGraph · AnimationService · Animator · AssetService · Atmosphere · Attachment · Backpack · BackpackItem · BasePlayerGui · Beam · BindableEvent · BindableFunction · Camera · CharacterAppearance · CharacterController · Chat · ClickDetector · Clouds · Collider · ComponentService · Constraint · CoreGui · DataModel · DataModelMesh · Debris · DecalProjector · Dragger · ExecutionGroup · Explosion · FaceInstance · FogVolume · Folder · ForceField · GraphicsService · GravityField · GuiBase · GuiBase3d · GuiService · Health · HistoryService · HttpService · Humanoid · HumanoidDescription · InputService · Keyframe · KeyframeMarker · KeyframeSequence · Light · Lighting · LightProbeVolume · LocalizationService · LogService · LuaSourceContainer · MaterialService · MaterialVariant · Motor6D · Mouse · NetworkClient · NetworkServer · NetworkService · NetworkSettings · NoCollisionConstraint · PartAdornment · ParticleAttractor · ParticleEmitter · ParticleOperator · PathfindingLink · PathfindingModifier · PathfindingService · PhysicsService · PhysicsSettings · PlaceService · Player · Players · PlayerScripts · Pose · PostEffect · PrefabService · ProximityPrompt · ProximityPromptService · PVAdornment · PVInstance · ReflectionProbe · ReflectionService · RemoteEvent · RemoteFunction · ReplicatedFirst · ReplicatedStorage · ReplicationService · RetargetProfile · RigControl · RunService · ScriptContext · Selection · ServerScriptService · ServerStorage · ShaderEffect · Sky · Sound · SoundEffect · SoundGroup · SoundService · StarterGui · StarterPack · StarterPlayer · StarterPlayerScripts · Stats · StatsItem · StorageService · SurfaceAppearance · SurfaceShader · TagService · Team · Teams · TestService · TextService · Tool · Trail · TranslationTable · TweenService · UIBase · ValueBase · VRService · WeldConstraint