getrawmetatable
Retrieves the actual metatable of any object, bypassing __metatable locks.
function getrawmetatable(objectobjectanyThe object to retrieve the raw metatable from.: any): tabletableThe unguarded metatable of the provided object.Usage
Unlock and modify a metatable
local mt = getrawmetatable(game)
-- Make the metatable writable
setreadonly(mt, false)
-- Now you can replace metamethods
mt.__index = function(self, key)
print("Property accessed:", key)
return rawget(mt, key)
end