Skip to content
Saiko

setrawmetatable

Replaces an object's metatable regardless of __metatable protection.

Signature

luau
setrawmetatable<T>(object: T, metatable: { [any]: any }?): T

Parameters

objecttable | Instance

The object to modify.

metatabletable?

The metatable to install, or nil to clear it.

Returns

table

Example

luau
local object = {}
setrawmetatable(object, {
    __index = function(_, key)
        return "no " .. key
    end,
})
print(object.anything) --> no anything