# Instance

### Instance

`Address` (number): The raw memory address of this instance.

```lua
local prim = part:Primitive()
print(prim.Address)
```

`inst:Name()`: Returns the instance's name as a string.

```lua
local name = inst:Name()
print(name)
```

`inst:SetName(name)`: Sets the instance's name.

```lua
inst:SetName("NewName")
```

`inst:Class()`: Returns the class name of the instance as a string.

```lua
local class = inst:Class()
print(class) -- "Part", "Model", etc.
```

`inst:Parent()`: Returns the parent of this instance.

```lua
local parent = inst:Parent()
print(parent:Name())
```

`inst:SetParent(instance)`: Sets the parent of this instance.

```lua
inst:SetParent(workspace)
```

`inst:IsA(class)`: Returns `true` if the instance is of the given class or inherits from it.

```lua
if inst:IsA("BasePart") then
    print("it's a part")
end
```

`inst:FindFirstChild(name)`: Returns the first direct child with the given name, or an empty Instance if not found.

```lua
local workspace = dm:FindFirstChild("Workspace")
print(workspace:Name())
```

`inst:FindFirstChildOfClass(class)`: Returns the first direct child of the given class.

```lua
local humanoid = character:FindFirstChildOfClass("Humanoid")
print(humanoid:Name())
```

`inst:GetChildren()`: Returns a table of all direct children as Instance objects.

```lua
local children = workspace:GetChildren()
for _, child in ipairs(children) do
    print(child:Name())
end
```

`inst:GetDescendants()`: Returns a table of every descendant recursively as Instance objects.

```lua
local descendants = workspace:GetDescendants()
for _, desc in ipairs(descendants) do
    print(desc:Name())
end
```

`inst:FindChildrenByName(name)`: Returns a table of all direct children matching the given name.

```lua
local parts = workspace:FindChildrenByName("Part")
for _, part in ipairs(parts) do
    print(part:Name())
end
```

`inst:FindChildrenByClass(class)`: Returns a table of all direct children matching the given class.

```lua
local parts = workspace:FindChildrenByClass("MeshPart")
for _, part in ipairs(parts) do
    print(part:Name())
end
```

`inst:Primitive()`: Returns the Primitive object for this instance if it is a physical part. Use this to read or modify physics and transform properties.

```lua
local prim = part:Primitive()
print(prim:Position().x)
```

`inst:GetNumberValue()`: Reads the value of a NumberValue instance and returns it as a float.

```lua
local val = numberValueInstance:GetNumberValue()
print(val)
```

`inst:SetNumberValue(value)`: Writes a new value to a NumberValue instance.

```lua
numberValueInstance:SetNumberValue(42.0)
```

`inst:GetAttributeString(name)`: Returns a string attribute by name.

```lua
local val = part:GetAttributeString("Tag")
print(val)
```

`inst:GetAttributeFloat(name)`: Returns a float attribute by name.

```lua
local speed = part:GetAttributeFloat("Speed")
print(speed)
```

`inst:GetAttributeInt(name)`: Returns an integer attribute by name.

```lua
local level = part:GetAttributeInt("Level")
print(level)
```

`inst:GetAttributeBool(name)`: Returns a boolean attribute by name.

```lua
local active = part:GetAttributeBool("IsActive")
print(active)
```

`inst:SetAttributeString(name, value)`: Sets a string attribute by name.

```lua
part:SetAttributeString("Tag", "enemy")
```

`inst:SetAttributeFloat(name, value)`: Sets a float attribute by name.

```lua
part:SetAttributeFloat("Speed", 16.5)
```

`inst:SetAttributeInt(name, value)`: Sets an integer attribute by name.

```lua
part:SetAttributeInt("Level", 5)
```

`inst:SetAttributeBool(name, value)`: Sets a boolean attribute by name.

```lua
part:SetAttributeBool("IsActive", true)
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://yerba-1.gitbook.io/yerba-docs/api/instance.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
