> ## Documentation Index
> Fetch the complete documentation index at: https://ugcore.urging.ch/llms.txt
> Use this file to discover all available pages before exploring further.

# UgLib.Entity

> Find the closest or nearby peds, vehicles, objects and players.

<Badge color="green">Client</Badge> Runs in your resource.

```lua theme={"dark"}
UgLib.Entity.GetClosestPed(coords?, maxDistance?, options?) -> entity, distance
UgLib.Entity.GetClosestVehicle(coords?, maxDistance?, options?) -> entity, distance
UgLib.Entity.GetClosestObject(coords?, maxDistance?, options?) -> entity, distance
UgLib.Entity.GetClosestPlayer(coords?, maxDistance?, options?) -> player
UgLib.Entity.GetNearbyPeds(coords?, radius, options?) -> { entity, distance }[]
UgLib.Entity.GetNearbyVehicles(coords?, radius, options?) -> { entity, distance }[]
UgLib.Entity.GetNearbyObjects(coords?, radius, options?) -> { entity, distance }[]
UgLib.Entity.GetNearbyPlayers(coords?, radius, options?) -> player[]
```

* `coords` defaults to the local player. `maxDistance` defaults to unlimited. Lists are sorted closest first. Nothing found returns `nil`.
* Peds skip the local player always, and player peds unless `includePlayers = true`. `exclude` skips one handle.
* Players skip the local player unless `includeSelf = true`. A player is `{ playerId, serverId, ped, distance }`.

## Example

```lua client.lua theme={"dark"}
local player = UgLib.Entity.GetClosestPlayer(nil, 3.0)

if player then
    UgCore.Network.TriggerServer('my-police:Cuff', player.serverId)
end
```


## Related topics

- [UgLib.Raycast and Screen](/ug-lib/raycast.md)
- [UgLib.Animation](/ug-lib/animation.md)
- [UgLib.Version](/ug-lib/version.md)
- [UgLib.Enums](/ug-lib/enums.md)
- [UgLib.Locale](/ug-lib/locale.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.