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

# hasmetafield

> Returns whether the target value has a non-nil raw metafield with the requested name. The function does not call the metafield, does not invoke __index lookup, and does not change readonly state.

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

  ## Arguments

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

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

  ## Returns

  <ResponseField name={"hasField"} type={"boolean"}>
    true when the raw metafield exists and is non-nil; otherwise false.
  </ResponseField>

  ## Example

  Check whether a value has a non-nil raw metafield.

  ```lua theme={null}
  local target = {}
  local meta = {
      __index = {},
  }

  setrawmetatable(target, meta)

  print(hasmetafield(target, "__index"))
  print(hasmetafield(target, "__newindex"))
  ```
</div>
