> For the complete documentation index, see [llms.txt](https://hrscripts.gitbook.io/hrscripts-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hrscripts.gitbook.io/hrscripts-documentation/resources/hrlib/modules/closest/client.md).

# Client

## ClosestPed

Function to get the closest ped to the player

```lua
function HRLib.ClosestPed(returnClosePeds: boolean?):
{ ped: integer, distance: number }? closestPed,
{ ped: integer, distance: number }[]? closePeds
```

Parameters description

* `returnClosePeds` - sets whether or not return all close peds found

Return description

* `closestPed` - the closest ped to the player with its ped Id and distance between the peds
* `closePeds` - all close peds found around the player with their ped Ids and distances between them and the player (<mark style="color:orange;">only available when returnClosePeds is true</mark>)

## ClosestVehicle

Function to get the closest vehicle to the player

```lua
function HRLib.ClosestVehicle(returnCloseVehs: boolean?):
{ vehicle: integer, distance: number }? closestVehicle,
{ vehicle: integer, distance: number }[]? closeVehicles
```

Parameters description

* `returnCloseVehs` - sets whether or not return all close vehicles found

Return description

* `closestVehicle` - the closest vehicle to the player with its vehicle Id\
  and distance between the player and vehicle
* `closeVehicles` - all close vehicles found around the player with their vehicle Ids and distances between the player and them (<mark style="color:orange;">only available when returnCloseVehs is true</mark>)

## ClosestObject

Function to get the closest object to the player

```lua
function HRLib.ClosestObject(returnCloseObjects: boolean?):
{ entity: integer, distance: number }? closestObject,
{ entity: integer, distance: number }[]? closeObjects
```

Parameters description

* `returnCloseObjects` - sets whether or not return all close objects found

Return description

* `closestObject` - the closest object to the player with its object Id\
  and distance between the player and object
* `closeObjects` - all close objects found around the player with their object Ids and distances between the player and them (<mark style="color:orange;">only available when returnCloseObjects is true</mark>)

## ClosestIPlayer

Function to get the information of IPlayer for the closest player to the current player

```lua
function HRLib.ClosestIPlayer(returnCloseIPlayers: boolean?):
HRLibCloseIPlayer? closestIPlayer,
HRLibCloseIPlayer[]? closeIPlayers
```

Parameters description

* `returnCloseIPlayers` - sets whether or not return all close IPlayers found around the player

Return description

* `closestIPlayer` - the closest player's IPlayer information
* `closeIPlayers` - all close players' IPlayer information\
  (<mark style="color:orange;">only available when returnCloseIPlayers is true</mark>)
