evasivedocs
Roblox scriptingLuau 0.748 · 24 guides · 385 API entries
API reference

Instances and parts

Every Roblox object, parts, models and value objects.

Instance

Every Roblox object. Properties and children are read live from the game. Reading a name that is no property or method gives the child of that name (workspace.Map), and a missing one raises "X is not a valid member of ...". Instances compare with == and work as table keys. Properties are read-only unless their entry says otherwise.

22 entries

Instance.new

functionNot available
Instance.new(className [, parent]) -> Instance

Would create a new object.

Warning

An external VM cannot create Roblox objects. Work with the objects the game already has.

Arguments
NameTypeDescription
classNamestring
parentoptionalInstance
Returns
  • Instance

Instance.Name

field

The object's name.

Returns
  • string

Instance.ClassName

field

Its class, e.g. "Part" or "Humanoid".

Returns
  • string

Instance.Parent

field

The object it sits in, or nil for the game itself.

Returns
  • Instance?

Instance.Address

field

The object's address in memory, for memory_read. To compare objects use ==.

Returns
  • number

Instance:FindFirstChild

method
Instance:FindFirstChild(name [, recursive]) -> Instance?

The first child called name (exact, case and spaces included), or nil. With recursive, every descendant is searched.

Arguments
NameTypeDescription
namestring
recursiveoptionalboolean
Returns
  • Instance?
Example
Luau
local hum = character:FindFirstChild("Humanoid")

Instance:FindFirstChildOfClass

method
Instance:FindFirstChildOfClass(className) -> Instance?

The first child whose ClassName is className.

Arguments
NameTypeDescription
classNamestring
Returns
  • Instance?
Example
Luau
character:FindFirstChildOfClass("Humanoid")

Instance:FindFirstChildWhichIsA

method
Instance:FindFirstChildWhichIsA(className) -> Instance?

The first child that IsA className (subclasses count).

Arguments
NameTypeDescription
classNamestring
Returns
  • Instance?
Example
Luau
model:FindFirstChildWhichIsA("BasePart")

Instance:FindFirstDescendant

method
Instance:FindFirstDescendant(name) -> Instance?

The first descendant called name.

Arguments
NameTypeDescription
namestring
Returns
  • Instance?

Instance:FindFirstAncestor

method
Instance:FindFirstAncestor(name) -> Instance?

The nearest ancestor called name.

Arguments
NameTypeDescription
namestring
Returns
  • Instance?

Instance:FindFirstAncestorOfClass

method
Instance:FindFirstAncestorOfClass(className) -> Instance?

The nearest ancestor whose ClassName is className.

Arguments
NameTypeDescription
classNamestring
Returns
  • Instance?
Example
Luau
part:FindFirstAncestorOfClass("Model")

Instance:FindFirstAncestorWhichIsA

method
Instance:FindFirstAncestorWhichIsA(className) -> Instance?

The nearest ancestor that IsA className.

Arguments
NameTypeDescription
classNamestring
Returns
  • Instance?

Instance:IsA

method
Instance:IsA(className) -> boolean

true when the object is of className or inherits from it (a Part IsA BasePart and a PVInstance).

Arguments
NameTypeDescription
classNamestring
Returns
  • boolean
Example
Luau
if obj:IsA("BasePart") then end

Instance:GetFullName

method
Instance:GetFullName() -> string

The dotted path from the game down, e.g. "Workspace.Map.Door".

Returns
  • string

Instance:GetChildren

method
Instance:GetChildren() -> { Instance }

The direct children.

Returns
  • { Instance }
Example
Luau
for _, c in ipairs(workspace:GetChildren()) do end

Instance:GetDescendants

method
Instance:GetDescendants() -> { Instance }

Every object below this one. On game it is a very long list.

Returns
  • { Instance }

Instance:IsDescendantOf

method
Instance:IsDescendantOf(ancestor) -> boolean

true when the object sits somewhere inside ancestor.

Arguments
NameTypeDescription
ancestorInstance
Returns
  • boolean

Instance:IsAncestorOf

method
Instance:IsAncestorOf(descendant) -> boolean

true when descendant sits somewhere inside this object.

Arguments
NameTypeDescription
descendantInstance
Returns
  • boolean

Instance:WaitForChild

method
Instance:WaitForChild(name [, timeout]) -> Instance?

Yields until a child called name exists and returns it. Without timeout it warns "Infinite yield possible" after 5 seconds and keeps waiting. With a timeout it returns nil when the time runs out.

Arguments
NameTypeDescription
namestring
timeoutoptionalnumber
Returns
  • Instance?
Example
Luau
local gui = player:WaitForChild("PlayerGui", 10)

Instance:GetAttribute

method
Instance:GetAttribute(name) -> any

The value of an attribute, or nil.

Arguments
NameTypeDescription
namestring
Returns
  • any
Example
Luau
print(part:GetAttribute("Owner"))

Instance:GetAttributes

method
Instance:GetAttributes() -> { [string]: any }

Every attribute, as a name to value table.

Returns
  • { [string]: any }
Example
Luau
for name, value in pairs(part:GetAttributes()) do end

Instance:SetAttribute

methodWorks differently
Instance:SetAttribute(name, value)

Changes an attribute's value.

Note

Only an attribute the object already has, set to a value of the same type (a string no longer than the space the old one takes). A new attribute or another type raises: an external VM cannot allocate Roblox's storage.

Arguments
NameTypeDescription
namestring
valueany
Example
Luau
part:SetAttribute("Level", 5)

PVInstance

What parts and models share: a pivot that places them.

2 entries

PVInstance:GetPivot

method
PVInstance:GetPivot() -> CFrame

The world pivot of the part or model.

Returns
  • CFrame
Example
Luau
print(workspace.Part:GetPivot().Position)

PVInstance:PivotTo

method
PVInstance:PivotTo(target)

Moves the part or model so its pivot is at target. Writes the position of every part in it.

Arguments
NameTypeDescription
targetCFrame
Example
Luau
model:PivotTo(CFrame.new(0, 50, 0))

Model

A group of parts, like a character.

2 entries

Model.PrimaryPart

field

The part the model is placed by, or nil.

Returns
  • BasePart?

Model:GetExtentsSize

method
Model:GetExtentsSize() -> Vector3

The size of the box around every part of the model, along the PrimaryPart's axes (the world axes without one). Vector3.zero for a model without parts.

Returns
  • Vector3
Example
Luau
local size = character:GetExtentsSize()

BasePart

Every kind of part (Part, MeshPart, ...). Position, CFrame, Velocity, AssemblyLinearVelocity and CanCollide can be written: the value goes into the part's physics data in Roblox's memory, and the wrong type raises. The rest are read-only.

12 entries

BasePart.Size

field

The part's size in studs.

Returns
  • Vector3

BasePart.Position

field

Where the part is. Writable.

Returns
  • Vector3
Example
Luau
part.Position = part.Position + Vector3.new(0, 5, 0)

BasePart.CFrame

field

Position and rotation. Writable.

Returns
  • CFrame

BasePart.Transparency

field

0 opaque to 1 invisible.

Returns
  • number

BasePart.Color

field

The part's colour.

Returns
  • Color3

BasePart.Velocity

field

Linear velocity in studs per second. Writable.

Returns
  • Vector3

BasePart.AssemblyLinearVelocity

field

The velocity of the assembly the part is in. Writable.

Returns
  • Vector3

BasePart.AssemblyAngularVelocity

field

The assembly's spin, in radians per second.

Returns
  • Vector3

BasePart.Anchored

field

true when physics does not move it.

Returns
  • boolean

BasePart.CanCollide

field

Whether it collides. Writable.

Returns
  • boolean

BasePart.CanTouch

field

Whether it fires touch events.

Returns
  • boolean

BasePart.CanQuery

field

Whether raycasts in the game can hit it.

Returns
  • boolean

MeshPart

A part with a mesh.

2 entries

MeshPart.MeshId

field

The mesh asset.

Returns
  • string

MeshPart.TextureId

field

The texture asset.

Returns
  • string

ValueBase

NumberValue, IntValue, BoolValue, StringValue, Vector3Value, Color3Value, CFrameValue and ObjectValue.

1 entry

ValueBase.Value

field

The stored value. Read-only.

Returns
  • any
Example
Luau
print(stats.Kills.Value)