setrawmetatable

Changes an object's real metatable.

Syntax

Signature
setrawmetatable(Object: any, Metatable: table?) -> any

Aliases

This function has no aliases.

Parameters

ParameterTypeDescription
ObjectanyValue whose metatable should be changed.
Metatabletable?New metatable, or nil to remove it.

Returns

TypeDescription
anyThe 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)