# Base Functions

## Toggle Type

{% tabs %}
{% tab title="Usage" %}

```javascript
<void> api:Toggle(<string> Type)
```

{% endtab %}

{% tab title="Example" %}

```lua
esp:Toggle("Boxes")

aimbot:Toggle("Aimbot")
```

{% endtab %}
{% endtabs %}

Toggles the specified `Type`.\
Only works on types with an `Enabled` option.

## Get Option Value

{% tabs %}
{% tab title="Usage" %}

```javascript
<variant> api:Get(<string> Type, <string> Option)
```

{% endtab %}

{% tab title="Example" %}

```lua
print(esp:Get("Boxes", "Color"))

print(aimbot:Get("Aimbot", "Strength"))
```

{% endtab %}
{% endtabs %}

Returns the specified `Option`'s value.

## Set Option Value

{% tabs %}
{% tab title="Usage" %}

```javascript
<void> api:Set(<string> Type, <string> Option, <variant> Value)
```

{% endtab %}

{% tab title="Example" %}

```lua
-- code
```

{% endtab %}
{% endtabs %}

Sets the specified `Option`'s value to `Value`.

## Set Function

{% tabs %}
{% tab title="Usage" %}

```javascript
<void> api:SetFunction(<string> Function, <function> NewFunction)
```

{% endtab %}

{% tab title="Example" %}

```lua
esp:SetFunction("health", function(plr)
    local Humanoid = plr.Character.Humanoid
    return {Humanoid.Health, Humanoid.MaxHealth}
end)

local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local Camera = workspace.CurrentCamera
aimbot:SetFunction("closest", function(plr)
    local Mouse = UserInputService:GetMouseLocation()
    local Player = nil
    local Closest = math.huge
    local MyTeam = Players.LocalPlayer.Team
    
    for i,v in next, Players:GetPlayers() do -- Iterate through all the players
        if v ~= Players.LocalPlayer and v.Character ~= nil then -- Check if the player is not you and if the player is alive
            local Position = v.Character:GetPivot() -- GetPivot() returns the Model's position
            local Vector, inViewport = Camera:WorldToViewportPoint(Position) -- Get the character's screen position
            if inViewport then -- Check if the character is on-screen
                local Distance = (Vector2.new(Mouse.X, Mouse.Y) - Vector2.new(Vector.X, Vector.Y)).Magnitude -- Get the distance between the Mouse and the character's on-screen position
                local Team = v.Team
                if Mag < Closest and Team ~= MyTeam then -- Check if the distance is closer than the closest distance and if the player is on a different team
                    Player = v
                    Closest = Distance -- Now it will filter out all players who are further than this distance
                end
            end
        end
    end
    return Player
end)
```

{% endtab %}

{% tab title="Functions" %}
These are available on both Universal Esp and Aimbot!\
Function names are not case-sensitive.

| Name         | Description                                                                                                                                                                | Parameters | Return Value Type                    |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------- | ------------------------------------ |
| alive        | Returns a boolean indicating if the `Player` is alive.                                                                                                                     | Player     | Boolean                              |
| character    | Returns the `Player`'s character.                                                                                                                                          | Player     | Instance (Model with ALL body parts) |
| team         | Return's the `Player`'s team. This **does not** have to be a `Team` object.                                                                                                | Player     | Any                                  |
| ffa          | <p>Returns a boolean indicating if the teams are free-for-all.<br>You <strong>must</strong> replace this function if you have replaced the <code>team</code> function.</p> | None       | Boolean                              |
| {% endtab %} |                                                                                                                                                                            |            |                                      |

{% tab title="Esp Functions" %}
These are only available on Universal Esp.\
Function names are not case-sensitive.

| Name         | Description                               | Parameters | Return Value Type               |
| ------------ | ----------------------------------------- | ---------- | ------------------------------- |
| health       | Returns the `Player`'s health in a table. | Player     | Table Ex. `{Health, MaxHealth}` |
| teamcolor    | Returns the `Player`'s team color.        | Player     | Color3                          |
| {% endtab %} |                                           |            |                                 |

{% tab title="Aimbot Functions" %}
These are only available on Universal Aimbot.\
Function names are not case-sensitive.

| Name          | Description                                              | Parameters | Return Value Type                 |
| ------------- | -------------------------------------------------------- | ---------- | --------------------------------- |
| closest       | Returns the closest `Player`.                            | None       | Player (the actual Player object) |
| visible       | Returns a boolean indicating is the `Player` is visible. | Player     | Boolean                           |
| {% endtab %}  |                                                          |            |                                   |
| {% endtabs %} |                                                          |            |                                   |

Replaces the script's `Function` with `NewFunction`.

## Reset Function

{% tabs %}
{% tab title="Usage" %}

```javascript
<void> api:ResetFunction(<string> Function)
```

{% endtab %}

{% tab title="Example" %}

```lua
esp:ResetFunction("health")

aimbot:ResetFunction("closest")
```

{% endtab %}
{% endtabs %}

Resets the script's `Function` to the original function.

## Destroy

{% tabs %}
{% tab title="Usage" %}

```javascript
<void> api:Destroy(<void>)
```

{% endtab %}

{% tab title="Example" %}

```lua
esp:Destroy()

aimbot:Destroy()
```

{% endtab %}
{% endtabs %}

Removes all drawing objects and stops the script.

## Version

{% tabs %}
{% tab title="Usage" %}

```javascript
<string> api.Version
```

{% endtab %}

{% tab title="Example" %}

```lua
print(esp.Version)

print(aimbot.Version)
```

{% endtab %}
{% endtabs %}

A string that specifies the script's version.


---

# 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://zzerexx.gitbook.io/universal-script-api/base-functions.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.
