setrawmetatable Synchronous
Replace or clear a table, userdata, or string metatable directly. It is useful for a local object whose metamethod behavior you control.
Luau
setrawmetatable(
value: Table | userdata | string,
metatable: Table?
) -> Table | userdata | stringParameters
| Parameter | Type | Description |
|---|---|---|
value | Table | userdata | string | Table, userdata, or string to update. |
metatable | Table? | Replacement table, or nil to clear the metatable. |
Returns
Table | userdata | stringThe original value.
Usage notes
Passing a Roblox Instance returns that Instance without changing its metatable.
Example
Luau
local object = {}
setrawmetatable(object, { __tostring = function() return "ready" end })
print(tostring(object)) -- ready