Volt

isreadonly

Checks if a table is read-only.

Syntax

isreadonly(table: table) -> boolean

Parameters

ParameterTypeDescription
tabletableThe table to check

Returns

TypeDescription
booleantrue 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)) -- false

Before Modifying

local mt = getrawmetatable(game)

if isreadonly(mt) then
    setreadonly(mt, false)
    -- Now safe to modify
    mt.__index = myCustomIndex
    setreadonly(mt, true)
end

On this page