hasmetatable Synchronous

Check whether a value has any metatable at all. This is a quick guard before reading or changing metamethods.

Syntax
Luau
hasmetatable(value: any) -> boolean

Parameters

Function parameters
ParameterTypeDescription
valueanyValue to inspect.

Returns

boolean

true if a raw metatable exists.

Example

Example
Luau
local object = setmetatable({}, {})
print(hasmetatable(object)) -- true
print(hasmetatable({})) -- false
Kawaii documentation