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

# FindKeyHanger

Finds the nearest keyhanger, optionally filtered by distance and model. Only enabled keyhangers are searched.

<table>
  <thead>
    <tr>
      <th scope="col">
        Argument
      </th>

      <th scope="col">
        Data Type
      </th>

      <th scope="col">
        Needed
      </th>

      <th scope="col">
        Default
      </th>

      <th scope="col">
        Description
      </th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <th>`coords`</th>
      <td>vector3</td>
      <td>❌</td>
      <td>`nil`</td>
      <td>The coordinates to search from, if `nil` the distance is ignored and a matching keyhanger is returned</td>
    </tr>

    <tr>
      <th>`distance`</th>
      <td>number</td>
      <td>❌</td>
      <td>`nil`</td>
      <td>The maximum distance from `coords`, if `nil` there is no limit</td>
    </tr>

    <tr>
      <th>`model`</th>
      <td>string</td>
      <td>❌</td>
      <td>`nil`</td>
      <td>Only match keyhangers of this model, if `nil` every model is matched</td>
    </tr>
  </tbody>
</table>

> **Returns**
>
> <table>
>   <thead>
>     <tr>
>       <th scope="col">
>         Type
>       </th>
>
>       <th scope="col">
>         Description
>       </th>
>     </tr>
>   </thead>
>
>   <tbody>
>     <tr>
>       <td>number | nil</td>
>
>       <td>
>         The id of the nearest matching keyhanger, or `nil` if none was found
>       </td>
>     </tr>
>   </tbody>
> </table>

> **Example**
>
> ```lua theme={null}
> local hangerId = exports["utility_keyhanger"]:FindKeyHanger(GetEntityCoords(GetPlayerPed(source)), 3.0)
>
> if hangerId then
>     print("Found the keyhanger", hangerId)
> end
> ```


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