Skip to content
Saiko

setreadonly

Freezes or unfreezes a table. Call it before writing to a game metatable, and restore the original state afterwards.

Signature

luau
setreadonly(object: table, readonly: boolean): ()

Parameters

objecttable

The table to change.

readonlyboolean

true to freeze, false to unfreeze.

Returns

Nothing.

Example

luau
local meta = getrawmetatable(game)
setreadonly(meta, false)
meta.__index = meta.__index -- writes now succeed
setreadonly(meta, true)