setrawmetatable
Changes an object's real metatable.
Syntax
Signature
setrawmetatable(Object: any, Metatable: table?) -> anyAliases
This function has no aliases.
Parameters
| Parameter | Type | Description |
|---|---|---|
Object | any | Value whose metatable should be changed. |
Metatable | table? | New metatable, or nil to remove it. |
Returns
| Type | Description |
|---|---|
any | The original Object. |
Notes
Pass nil to remove it. Returns Object.
Example
Luau
local Object = {}
setrawmetatable(Object, {__index = function() return 42 end})
assert(Object.Value == 42)