> For the complete documentation index, see [llms.txt](https://limedocs.gitbook.io/limeutils/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://limedocs.gitbook.io/limeutils/how-to-use/main-docs.md).

# Main Docs

Main Docs of Lime Utils

#### `util.username()`

Returns the username of the local player.

**Returns:**

* `string`: The username of the local player, or `"Player not found"` if the player is not available.

**Example:**

```
print(util.username()) -- Output: "Player123"
```

***

#### `util.displayName()`

Returns the display name of the local player.

**Returns:**

* `string`: The display name of the local player, or `"DisplayName not found"` if the player is not available.

**Example:**

```
print(util.displayName()) -- Output: "CoolPlayer"
```

***

#### `util.userId()`

Returns the UserId of the local player.

**Returns:**

* `number`: The UserId of the local player, or `0` if the player is not available.

**Example:**

```
print(util.userId()) -- Output: 123456789
```

***

#### `util.realUsername()`

Returns the display name if available; otherwise, returns the username of the local player.

**Returns:**

* `string`: The display name or username of the local player, or `"Player not found"` if the player is not available.

**Example:**

```
print(util.realUsername()) -- Output: "CoolPlayer" or "Player123"
```

***

#### `util.getLocalPlayerThumbnail()`

Returns the thumbnail URL of the local player's avatar.

**Returns:**

* `string`: The URL of the player's thumbnail, or `nil` if the player is not available.

**Example:**

```
print(util.getLocalPlayerThumbnail()) -- Output: "http://www.roblox.com/..."
```

***

#### `util.getPlayerPosition()`

Returns the position of the local player's `HumanoidRootPart`.

**Returns:**

* `Vector3`: The position of the player, or `Vector3.new(0, 0, 0)` if the player or `HumanoidRootPart` is not found.

**Example:**

```
print(util.getPlayerPosition()) -- Output: Vector3(10, 5, 20)
```

***

#### `util.teleportPlayer(position)`

Teleports the local player to the specified position.

**Parameters:**

* `position` (`Vector3`): The target position to teleport the player to.

**Example:**

```
util.teleportPlayer(Vector3.new(100, 10, 50))
```

***

#### `util.getAllPlayers()`

Returns a list of all players in the game.

**Returns:**

* `table`: An array of all `Player` objects.

**Example:**

```
for _, player in ipairs(util.getAllPlayers()) do
    print(player.Name)
end
```

***

#### `util.setGravity(gravity)`

Sets the gravity of the game world.

**Parameters:**

* `gravity` (`number`): The gravity value to set (clamped between `0` and `196.2`).

**Example:**

```
util.setGravity(50) -- Low gravity mode
```

***

#### `util.getGravity()`

Returns the current gravity of the game world.

**Returns:**

* `number`: The current gravity value.

**Example:**

```
print(util.getGravity()) -- Output: 196.2
```

***

#### `util.playSound(soundId, options)`

Plays a sound with customizable options.

**Parameters:**

* `soundId` (`number`): The ID of the sound to play.
* `options` (`table`, optional): A table of options:
  * `volume` (`number`): Volume of the sound (default: `1`).
  * `looped` (`boolean`): Whether the sound should loop (default: `false`).
  * `parent` (`Instance`): The parent object for the sound (default: `workspace`).

**Returns:**

* `Sound`: The created `Sound` instance.

**Example:**

```
util.playSound(12345, {volume = 0.5, looped = true, parent = game.Workspace})
```

***

#### `util.stopAllSounds(parent)`

Stops all sounds in the specified parent object.

**Parameters:**

* `parent` (`Instance`, optional): The parent object to search for sounds (default: `workspace`).

**Example:**

```
util.stopAllSounds(game.Workspace)
```

***

#### `util.measurePerformance(func, ...)`

Measures the execution time of a function.

**Parameters:**

* `func` (`function`): The function to measure.
* `...` (`any`): Arguments to pass to the function.

**Returns:**

* `number`: The execution time in seconds.
* `...`: The results of the function.

**Example:**

```
local time, result = util.measurePerformance(function()
    return math.sqrt(144)
end)
print(time, result) -- Output: 0.0001, 12
```

***

#### `util.dumpObject(obj, maxDepth)`

Recursively dumps the contents of an object (table) into a string.

**Parameters:**

* `obj` (`table`): The object to dump.
* `maxDepth` (`number`, optional): The maximum depth to recurse (default: `3`).

**Returns:**

* `string`: A string representation of the object.

**Example:**

```
local myTable = {a = 1, b = {c = 2}}
print(util.dumpObject(myTable)) -- Output: "{a = 1, b = {c = 2}}"
```

***

#### `util.raycast(origin, direction, params)`

Performs a raycast in the game world.

**Parameters:**

* `origin` (`Vector3`): The starting point of the raycast.
* `direction` (`Vector3`): The direction of the raycast.
* `params` (`table`, optional): A table of parameters:
  * `filterType` (`Enum.RaycastFilterType`): The filter type (default: `Enum.RaycastFilterType.Blacklist`).
  * `ignoreList` (`table`): A list of objects to ignore (default: `{LocalPlayer.Character}`).
  * `ignoreWater` (`boolean`): Whether to ignore water (default: `true`).

**Returns:**

* `RaycastResult`: The result of the raycast.

**Example:**

```
local result = util.raycast(Vector3.new(0, 10, 0), Vector3.new(0, -1, 0), {
    ignoreList = {workspace.Part},
    ignoreWater = false
})
if result then
    print("Hit:", result.Instance.Name)
end
```

####
