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

# SetKeyHangerEnabled

Enables or disables a keyhanger. A disabled keyhanger is removed from the world but kept in the database and stays removed after a restart, enabling it recreates it.

<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>`hangerId`</th>
      <td>number</td>
      <td>✅</td>
      <td>`-`</td>
      <td>The id of the keyhanger</td>
    </tr>

    <tr>
      <th>`enabled`</th>
      <td>boolean</td>
      <td>✅</td>
      <td>`-`</td>
      <td>True to recreate the keyhanger, false to remove it from the world</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 status has been updated, false otherwise
>       </td>
>     </tr>
>
>     <tr>
>       <td>string | nil</td>
>
>       <td>
>         The error message if the status has not been updated (`KeyHanger not found`, or `Invalid keyhanger data` if the keyhanger could not be recreated, for example because its model has been removed from the config)
>       </td>
>     </tr>
>   </tbody>
> </table>

> **Example**
>
> ```lua theme={null}
> exports["utility_keyhanger"]:SetKeyHangerEnabled(hangerId, false)
> ```


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