getrawmetatable
Returns a value's metatable directly, ignoring any __metatable protection.
Syntax
getrawmetatable(object: any) -> table?
Also available as
debug.getmetatableget_raw_metatable
Parameters
| Parameter | Type | Description |
|---|---|---|
object | any | Any value: a table, an Instance, a string, a userdata. |
Returns
| Type | Description |
|---|---|
table? | The value's metatable, or nil when it has none. |
Description
getmetatable returns the __metatable field instead of the real metatable when one is set, which is how Instances hide theirs: getmetatable(game) returns the string "The metatable is locked". getrawmetatable always returns the real table, so you can read the metamethods behind it.
Example
local mt = getrawmetatable(game)
print(getmetatable(game))
print(type(mt.__index), type(mt.__namecall))
print(getrawmetatable("text").__index == string)
Notes
- An Instance's metatable is read-only. Use
setreadonlybefore changing it, or usehookmetamethod, which handles this for you.
These are Game executor contracts. Check build requirements and session lifetimes before using them.
