getmetafield Synchronous
Read one field directly from an object’s raw metatable. It is useful when you only need to inspect a specific metamethod without walking the whole table.
Luau
getmetafield(value: any, field: string) -> anyParameters
| Parameter | Type | Description |
|---|---|---|
value | any | Value with a metatable. |
field | string | Field name, such as "__index". |
Returns
anyThe raw field value, or nil when the field or metatable is absent.
Example
Luau
local object = setmetatable({}, { __tostring = function() return "item" end })
print(type(getmetafield(object, "__tostring"))) -- function