setreadonly
Freezes or unfreezes a table. Call it before writing to a game metatable, and restore the original state afterwards.
Signature
setreadonly(object: table, readonly: boolean): ()Parameters
objecttableThe table to change.
readonlybooleantrue to freeze, false to unfreeze.
Returns
Nothing.
Example
local meta = getrawmetatable(game)
setreadonly(meta, false)
meta.__index = meta.__index -- writes now succeed
setreadonly(meta, true)