Metatables
Metatables, readonly state, and namecall methods.
Functions
debug.getmetatableRead an object’s raw metatable through the debug namespace. It has the same behavior as getrawmetatable, which is convenient when related inspection code already lives under debug.
debug.setmetatableSet an object’s raw metatable through the debug namespace. It follows the same behavior as setrawmetatable and returns the object you supplied.
getmetafieldRead one field directly from an object’s raw metatable. It is useful when you only need to inspect a specific metamethod without walking the whole table.
getnamecallmethodRead the method name associated with the current Roblox namecall. It is most useful inside a __namecall hook where the same metamethod handles many method names.
getrawmetatableRead an object’s actual metatable, even when normal metatable access is protected. Use it to inspect metamethods such as __index or __tostring.
hasmetafieldCheck whether an object’s raw metatable defines a non-nil field. Use it before taking a path that depends on a particular metamethod.
hasmetatableCheck whether a value has any metatable at all. This is a quick guard before reading or changing metamethods.
isreadonlyCheck whether a table currently rejects writes. This is useful before a temporary table edit that you plan to put back afterward.
iswritableCheck whether a table is currently writable. It is the inverse of isreadonly for the same table.
makereadonlyMark a table read-only after you finish populating it. This is a quick way to stop accidental later writes to a shared configuration table.
makewriteableClear a table’s read-only flag so its fields can be changed. The name is spelled writeable in the API.
setnamecallmethodChange the method name attached to the current namecall context. This is useful when forwarding a namecall through a different method name in a controlled hook.
setrawmetatableReplace or clear a table, userdata, or string metatable directly. It is useful for a local object whose metamethod behavior you control.
setreadonlySet or clear a table’s read-only flag explicitly. Use it when you need to make a controlled change to a table and restore its earlier protection afterward.