> For the complete documentation index, see [llms.txt](https://zzerexx.gitbook.io/universal-script-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://zzerexx.gitbook.io/universal-script-api/base-functions.md).

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