isreadonly
Checks if a table is read-only.
Syntax
isreadonly(table: table) -> booleanParameters
| Parameter | Type | Description |
|---|---|---|
table | table | The table to check |
Returns
| Type | Description |
|---|---|
boolean | true if the table is read-only |
Description
isreadonly returns whether a table has been marked as read-only, preventing modifications.
Example
local mt = getrawmetatable(game)
print(isreadonly(mt)) -- true (Roblox metatables are locked)
-- Normal tables are not read-only by default
local myTable = {a = 1}
print(isreadonly(myTable)) -- falseBefore Modifying
local mt = getrawmetatable(game)
if isreadonly(mt) then
setreadonly(mt, false)
-- Now safe to modify
mt.__index = myCustomIndex
setreadonly(mt, true)
endRelated Functions
setreadonly- Set read-only statusgetrawmetatable- Get the metatable