System

Instance

Uninstantiable

This object cannot be instantiated.

Every class dervies from Instance, and all classes have the same properties and methods as Instance.

Abstract class

Instance is an abstract class, meaning you cannot create an instance of Instance directly. Instead, you must create an instance of a class that derives from Instance.

Events

ChildAdded

Fires when a child is added to the instance.

Parameters

NameTypeDescription
childInstanceThe child that was added.

Example

Lua

game.Players.ChildAdded:Connect(function(player)
    print(player.Username .. " joined the game!")
end)

TypeScript

game.Players.ChildAdded.Connect((player: Player) => {
  print(player.Username + " joined the game!");
});

ChildRemoved

Fires when a child is removed from the instance.

Parameters

NameTypeDescription
childInstanceThe child that was removed.

Example

Lua

game.Players.ChildRemoved:Connect(function(player)
    print(player.Username .. " left the game!")
end)

TypeScript

game.Players.ChildRemoved.Connect((player: Player) => {
  print(player.Username + " left the game!");
});

Clicked

Fires when the instance is clicked.

Parameters

NameTypeDescription
playerPlayerThe player that clicked the instance.

Example

Lua

game.World:FindFirstChild("Button").Clicked:Connect(function(player)
  print(player.Username .. " clicked the button!")
end)

TypeScript

game.World.FindFirstChild("Button").Clicked.Connect((player: Player) => {
  print(player.Username + " clicked the button!");
});

MouseEnter

Fires when the mouse enters the instance.

Example

Lua

game.World:FindFirstChild("Button").MouseEnter:Connect(function()
  print("Mouse entered the button!")
end)

TypeScript

game.World.FindFirstChild("Button").MouseEnter.Connect(() => {
  print("Mouse entered the button!");
});

MouseLeave

Fires when the mouse leaves the instance.

Example

Lua

game.World:FindFirstChild("Button").MouseLeave:Connect(function()
  print("Mouse left the button!")
end)

TypeScript

game.World.FindFirstChild("Button").MouseLeave.Connect(() => {
  print("Mouse left the button!");
});

Touched

Fires when the instance is touched by another instance. To check if the instance was touched by a player, use the Player class with the IsA method. Debounce is recommended to prevent multiple touches.

Parameters

NameTypeDescription
otherInstanceThe instance that touched the object.

Example

Lua

game.World:FindFirstChild("Button").Touched:Connect(function(other)
  if other:IsA("Player") then
    print(other.Username .. " touched the button!")
  end
end)

TypeScript

game.World.FindFirstChild("Button").Touched.Connect((other: Instance) => {
  if (other.IsA("Player")) {
    print(other.Username + " touched the button!");
  }
});

Colliders

There must be a Collider attached to the instance for the Touched event to fire.

TouchEnded

Fires when the instance is no longer being touched by another instance.

Parameters

NameTypeDescription
otherInstanceThe instance that was touching the object.

Example

Lua

game.World:FindFirstChild("Button").TouchEnded:Connect(function(other)
  if other:IsA("Player") then
    print(other.Username .. " stopped touching the button!")
  end
end)

TypeScript

game.World.FindFirstChild("Button").TouchEnded.Connect((other: Instance) => {
  if (other.IsA("Player")) {
    print(other.Username + " stopped touching the button!");
  }
});

Colliders

There must be a Collider attached to the instance for the TouchEnded event to fire.

Methods

New

Creates a new instance of the class.

Returns

Returns Instance.

Clone

Creates a deep copy of the instance.

Returns

Returns void.

Destroy

Destroys the instance.

Returns

Returns void.

GetParent

Returns the parent of the instance. Same as accessing the Parent property.

Returns

Returns Instance.

SetParent

Sets the parent of the instance. Same as setting the Parent property.

Parameters

NameTypeDescription
newParentInstanceThe new parent of the instance.

Returns

Returns void.

IsA

Checks if the instance is of the specified class.

Parameters

NameTypeDescription
classNamestringThe name of the class to check.

Returns

Returns boolean.

IsDescendantOf

Checks if the instance is a descendant of the specified instance.

Parameters

NameTypeDescription
ancestorInstanceThe instance to check if it is an ancestor of the instance.

Returns

Returns boolean.

FindFirstChild

Finds the first child of the instance with the specified name.

Parameters

NameTypeDescription
namestringThe name of the child to find.

Returns

Returns Instance.

FindFirstChildOfClass

Finds the first child of the instance with the specified class.

Parameters

NameTypeDescription
classNamestringThe name of the class to find.

Returns

Returns Instance.

FindFirstChildWhichIsA

Finds the first child of the instance that is of the specified class.

Parameters

NameTypeDescription
classNamestringThe name of the class to find.

Returns

Returns Instance.

GetChildren

Returns a list of all children of the instance.

Returns

Returns Instance[].

GetDescendants

Returns a list of all descendants of the instance.

Returns

Returns Instance[].

WaitForChild

Waits for the child of the instance with the specified name to be added. Will yield the current thread until the child is added.

Parameters

NameTypeDescription
namestringThe name of the child to wait for.

Returns

Returns Instance.

WaitForChildOfClass

Waits for the child of the instance with the specified class to be added. Will yield the current thread until the child is added.

Parameters

NameTypeDescription
classNamestringThe name of the class to wait for

Returns

Returns Instance.

Properties

CanReparent

Returns whether the instance can be reparented or not.

Type

boolean

ClassName

Returns the name of the class of the instance.

Type

string

Actor

Returns the actor of the instance.

Type

Returns Actor.

Name

Returns the name of the instance.

Type

string

Parent

Returns the parent of the instance.

Type

Instance

Tags

An enumerable list of tags associated with the instance. Tags are used to identify instances with specific properties.

Example

Lua

game.World:FindFirstChild("Button").Tags = { "Clickable", "Interactive" }
-- Later...
if game.World:FindFirstChild("Button").Tags["Clickable"] then
  print("Button is clickable!")
end

TypeScript

game.World.FindFirstChild("Button").Tags = ["Clickable", "Interactive"];
// Later...
if (game.World.FindFirstChild("Button").Tags["Clickable"]) {
  print("Button is clickable!");
}

Type

string[]

Previous
DynamicInstance