# Cache

### Cache

`Cache.FetchLocalPlayer()`: Returns the `CachedPlayer` object for your own player.

```lua
local lp = Cache.FetchLocalPlayer()
print(lp.Name, lp.Health)
```

`Cache.FetchPlayers()`: Returns a table of all currently cached `CachedPlayer` objects. Always check `p.Valid` before reading data.

```lua
local players = Cache.FetchPlayers()
for _, p in ipairs(players) do
    if p.Valid then
        print(p.Name, p.Health)
    end
end
```

#### CachedPlayer fields

| Field              | Type       | Description                  |
| ------------------ | ---------- | ---------------------------- |
| `Address`          | number     | Raw memory address           |
| `Name`             | string     | Username                     |
| `DisplayName`      | string     | Display name                 |
| `Character`        | Instance   | Character in workspace       |
| `UserId`           | number     | Roblox UserId                |
| `Health`           | number     | Current health               |
| `MaxHealth`        | number     | Max health                   |
| `Visible`          | boolean    | Visible from camera          |
| `R15`              | boolean    | `true` if R15, `false` if R6 |
| `Head`             | CachedBone | Head bone                    |
| `HumanoidRootPart` | CachedBone | Root part bone               |
| `ToolName`         | string     | Currently held tool name     |
| `Desynced`         | boolean    | Is desynced                  |
| `Status`           | string     | Status string                |
| `Valid`            | boolean    | Safe to read                 |

`p:BoxMin()` (Vector2): Top-left corner of the 2D bounding box. `p:BoxMax()` (Vector2): Bottom-right corner of the 2D bounding box. `p:Bones()` (table): Table of `CachedBone` objects for the skeleton.

#### CachedBone fields

| Field            | Type     | Description                |
| ---------------- | -------- | -------------------------- |
| `Name`           | string   | Bone name                  |
| `ScreenPosition` | Vector2  | Projected screen position  |
| `WorldPosition`  | Vector3  | World position             |
| `Size`           | number   | Bone size                  |
| `Instance`       | Instance | Underlying Roblox instance |

`bone:Hull()`: Returns a table of `Vector2` points forming the bone's convex hull outline.

```lua
local hull = bone:Hull()
for i = 1, #hull do
    local a = hull[i]
    local b = hull[(i % #hull) + 1]
    Draw.Line(a, b, Color(255, 0, 0, 255), 1)
end
```


---

# 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/cache.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.
