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

# getmetafield

> Returns a raw metafield value from the target metatable. target may be any value, and field must be a string. The function does not call the metafield, does not invoke __index lookup, and returns nil when the metatable or field is missing.

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

  ## Argumente

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

  <ParamField path={"field"} type={"string"} required>
    Metafield name to read.
  </ParamField>

  ## Rückgaben

  <ResponseField name={"fieldValue"} type={"any | nil"}>
    Raw metafield value when present; otherwise nil.
  </ResponseField>

  ## Beispiel

  Read one raw metafield value from a value's metatable.

  ```lua theme={null}
  local target = {}
  local meta = {
      __index = function()
          return "fallback"
      end,
  }

  setrawmetatable(target, meta)

  local field = getmetafield(target, "__index")
  print(type(field))
  print(getmetafield(target, "__newindex"))
  ```
</div>
