Fandom

ROBLOX Wikia

Metatable

12,752pages on
this wiki
Add New Page
Comments0 Share

A metatable is a function that controls how a table acts in a ROBLOX place. For example, if one wanted to create a table with numbers and math functions while leaving the table intact, this function would be the solution to said problem.

Metamethods

A metamethod is a method called when an object or entity attempts to affect the table. They allow for easy manipulation of the table.

Metamethod Description
__index(table, index) Fired upon: table[index], when table[index] is nil
__newindex(table, index, value) Fired upon: table[index] = value, when table[index] is nil
__call(table, ...)

Fired upon: table(...), where ... are the arguments passed

__concat(table, value) Fired upon: table .. value
__unm(table) Fired upon: -table
__add(table, value) Fired upon: table + value
__sub(table, value) Fired upon: table - value
__mul(table, value) Fired upon: table * value
__div(table, value) Fired upon: table / value
__mod(table, value) Fired upon: table % value
__pow(table, value) Fired upon: table ^ value
__tostring(table) Fired upon: tostring(table)
__metatable Allows a custom return value upon the getmetatable() function
__eq(table, value) Fired upon: table == value
__lt(table, value) Fired upon: table < value, Opposite fired upon: table >= value
__le(table, value) Fired upon: table <= value, Opposite fired upon: table > value
__mode Used to declare weak keys/values
__gc(table) Fired upon: collectgarbage(table)
__len(table) Fired upon: #table

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.