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.
Instance.new(className [, parent]) -> InstanceWould create a new object.
An external VM cannot create Roblox objects. Work with the objects the game already has.
| Name | Type | Description |
|---|---|---|
className | string | |
parentoptional | Instance |
Instance
The object's name.
string
Its class, e.g. "Part" or "Humanoid".
string
The object it sits in, or nil for the game itself.
Instance?
The object's address in memory, for memory_read. To compare objects use ==.
number
Instance:FindFirstChild(name [, recursive]) -> Instance?The first child called name (exact, case and spaces included), or nil. With recursive, every descendant is searched.
| Name | Type | Description |
|---|---|---|
name | string | |
recursiveoptional | boolean |
Instance?
local hum = character:FindFirstChild("Humanoid")Instance:FindFirstChildOfClass(className) -> Instance?The first child whose ClassName is className.
| Name | Type | Description |
|---|---|---|
className | string |
Instance?
character:FindFirstChildOfClass("Humanoid")Instance:FindFirstChildWhichIsA(className) -> Instance?The first child that IsA className (subclasses count).
| Name | Type | Description |
|---|---|---|
className | string |
Instance?
model:FindFirstChildWhichIsA("BasePart")Instance:FindFirstDescendant(name) -> Instance?The first descendant called name.
| Name | Type | Description |
|---|---|---|
name | string |
Instance?
Instance:FindFirstAncestor(name) -> Instance?The nearest ancestor called name.
| Name | Type | Description |
|---|---|---|
name | string |
Instance?
Instance:FindFirstAncestorOfClass(className) -> Instance?The nearest ancestor whose ClassName is className.
| Name | Type | Description |
|---|---|---|
className | string |
Instance?
part:FindFirstAncestorOfClass("Model")Instance:FindFirstAncestorWhichIsA(className) -> Instance?The nearest ancestor that IsA className.
| Name | Type | Description |
|---|---|---|
className | string |
Instance?
Instance:IsA(className) -> booleantrue when the object is of className or inherits from it (a Part IsA BasePart and a PVInstance).
| Name | Type | Description |
|---|---|---|
className | string |
boolean
if obj:IsA("BasePart") then endInstance:GetFullName() -> stringThe dotted path from the game down, e.g. "Workspace.Map.Door".
string
Instance:GetChildren() -> { Instance }The direct children.
{ Instance }
for _, c in ipairs(workspace:GetChildren()) do endInstance:GetDescendants() -> { Instance }Every object below this one. On game it is a very long list.
{ Instance }
Instance:IsDescendantOf(ancestor) -> booleantrue when the object sits somewhere inside ancestor.
| Name | Type | Description |
|---|---|---|
ancestor | Instance |
boolean
Instance:IsAncestorOf(descendant) -> booleantrue when descendant sits somewhere inside this object.
| Name | Type | Description |
|---|---|---|
descendant | Instance |
boolean
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.
| Name | Type | Description |
|---|---|---|
name | string | |
timeoutoptional | number |
Instance?
local gui = player:WaitForChild("PlayerGui", 10)Instance:GetAttribute(name) -> anyThe value of an attribute, or nil.
| Name | Type | Description |
|---|---|---|
name | string |
any
print(part:GetAttribute("Owner"))Instance:GetAttributes() -> { [string]: any }Every attribute, as a name to value table.
{ [string]: any }
for name, value in pairs(part:GetAttributes()) do endInstance:SetAttribute(name, value)Changes an attribute's value.
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.
| Name | Type | Description |
|---|---|---|
name | string | |
value | any |
part:SetAttribute("Level", 5)PVInstance:GetPivot() -> CFrameThe world pivot of the part or model.
CFrame
print(workspace.Part:GetPivot().Position)PVInstance:PivotTo(target)Moves the part or model so its pivot is at target. Writes the position of every part in it.
| Name | Type | Description |
|---|---|---|
target | CFrame |
model:PivotTo(CFrame.new(0, 50, 0))The part the model is placed by, or nil.
BasePart?
Model:GetExtentsSize() -> Vector3The 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.
Vector3
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.
The part's size in studs.
Vector3
Where the part is. Writable.
Vector3
part.Position = part.Position + Vector3.new(0, 5, 0)Position and rotation. Writable.
CFrame
0 opaque to 1 invisible.
number
The part's colour.
Color3
Linear velocity in studs per second. Writable.
Vector3
The velocity of the assembly the part is in. Writable.
Vector3
The assembly's spin, in radians per second.
Vector3
true when physics does not move it.
boolean
Whether it collides. Writable.
boolean
Whether it fires touch events.
boolean
Whether raycasts in the game can hit it.
boolean
The mesh asset.
string
The texture asset.
string
ValueBase
NumberValue, IntValue, BoolValue, StringValue, Vector3Value, Color3Value, CFrameValue and ObjectValue.
The stored value. Read-only.
any
print(stats.Kills.Value)