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

# PlaceKeyHanger

Creates a new keyhanger and saves it to the database.

<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>`model`</th>
      <td>string</td>
      <td>✅</td>
      <td>`-`</td>
      <td>The keyhanger model (key) defined in `Config.KeyHangers`</td>
    </tr>

    <tr>
      <th>`coords`</th>
      <td>vector3</td>
      <td>✅</td>
      <td>`-`</td>
      <td>The coordinates where the keyhanger will be placed</td>
    </tr>

    <tr>
      <th>`rotation`</th>
      <td>vector3</td>
      <td>❌</td>
      <td>`vector3(0.0, 0.0, 0.0)`</td>
      <td>The rotation of the keyhanger</td>
    </tr>

    <tr>
      <th>`fromItem`</th>
      <td>boolean</td>
      <td>❌</td>
      <td>`false`</td>
      <td>If true the keyhanger can be picked up by players and given back as an item</td>
    </tr>
  </tbody>
</table>

> **Returns**
>
> <table>
>   <thead>
>     <tr>
>       <th scope="col">
>         Type
>       </th>
>
>       <th scope="col">
>         Description
>       </th>
>     </tr>
>   </thead>
>
>   <tbody>
>     <tr>
>       <td>boolean</td>
>
>       <td>
>         true if the keyhanger has been created, false otherwise
>       </td>
>     </tr>
>
>     <tr>
>       <td>number | string</td>
>
>       <td>
>         The id of the created keyhanger, or the error message if the keyhanger has not been created (`Invalid keyhanger data` if the model does not exist)
>       </td>
>     </tr>
>   </tbody>
> </table>

> **Example**
>
> ```lua theme={null}
> local success, hangerId = exports["utility_keyhanger"]:PlaceKeyHanger("mxc_keyhanger_prop_frame_1", vector3(100.0, 100.0, 30.0), vector3(0.0, 0.0, 90.0))
>
> if success then
>     print("KeyHanger created with id", hangerId)
> end
> ```


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