Skip to content

Instance

Instance is the base class of all classes. Every class derives from it and has all properties, events and functions Instance has.

Inherits: NetworkedObject

Properties

  • Parent: Instance
  • EditableChildren: boolean
  • Tags: { string }
  • Archivable: boolean

Methods

GetDescendants() → { Instance }

Gets all descendants of this instance.

FindChild(name: string) → Instance

Finds a child of this instance by name.

WaitChild(name: string, timeoutSec: number) → Instance

Wait for children to be added.

FindChildByClass(className: string) → Instance

Finds a child of this instance by class name.

FindChildWithTag(tag: string) → Instance

Find first child with the specified tag

GetChildrenWithTag(tag: string) → { Instance }

Get children with the specified tag

FindAncestorByClass(className: string) → Instance

Find ancestor by the specified class name

FindChildByIndex(index: number) → Instance

Find child by it's index (index for this function starts from 0)

MoveChild(child: Instance, index: number) → nil

Move children to specified index (index for this function starts from 0)

GetChildren() → { Instance }

Gets all children of this instance.

GetChildrenOfClass(className: string) → { Instance }

Gets all children of this instance that are of the specified class.

IsAncestorOf(instance: Instance) → boolean

Determines if this instance is an ancestor of the given instance.

IsDescendantOf(instance: Instance) → boolean

Determines if this instance is a descendant of the given instance.

IsDescendantOfClass(className: string) → boolean

Determines if this instance is a descendant of the given class.

New(className: string, parent: Instance) → Instance

Creates a new instance of the specified class.

AddTag(tag: string) → nil

Adds a tag to this instance.

RemoveTag(tag: string) → nil

Removes a tag from this instance.

HasTag(tag: string) → boolean

Checks if this instance has the specified tag.

Reparent(to: Instance) → nil

Reparent this instance to another instance

GetParent() → Instance

Gets the parent of this instance.

SetParent(newParent: Instance) → nil

Sets the parent of this instance.

Events

  • ChildAdded: Fires when child has been added to this instance
  • ChildRemoved: Fires when child has been removed from this instance (either via reparent or delete)
  • ChildDeleting: Fires when child is being deleted from this instance
  • ChildDeleted: Fires when child has been deleted from this instance