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

# setrawmetatable

> Sets the metatable for a target value and returns the original target. metatable must be a table or nil; nil clears the metatable. debug.setmethods is an alias for setrawmethods.

<div className="real-function-page">
  ```lua theme={null}
  setrawmetatable(target: any, metatable: table | nil): any
  ```

  ## Alias

  * `debug.setmetatable`

  ## Arguments

  <ParamField path={"target"} type={"any"} required>
    Value whose metatable is changed.
  </ParamField>

  <ParamField path={"metatable"} type={"table | nil"} required>
    New metatable, or nil to clear the metatable. Other types raise "nil or table".
  </ParamField>

  ## Retours

  <ResponseField name={"target"} type={"any"}>
    The original target value.
  </ResponseField>

  ## Exemple

  Set or clear a value's metatable and receive the target back.

  ```lua theme={null}
  local target = {}
  local meta = { label = "Real" }

  local returned = setrawmetatable(target, meta)
  print(returned == target)
  print(getrawmetatable(target) == meta)

  debug.setmetatable(target, nil)
  print(getrawmetatable(target))
  ```
</div>
