What are Metatables?

  1. What do you want to achieve? I want to know what metatables is in scripting.
  2. What is the issue? I watch tutorials and they never seem to help
  3. What solutions have you tried so far? Youtube, Developer Hub

Now please help. I cant every seem to understand what it means or does, and how did you learn it?

Metatables are a bit like events for tables for example when an index of nil is called you can assign a function to it.

Here are a few resources you could check out:

Basically they’re tables with extra values assigned to it

5 Likes

Think of it like putting a table with some extra data inside of the table.

table = {metatable = {}}

Except you can’t access metatables inside of this table by doing table.metatable. Instead you have to do getmetatable(table). On top of all that, metatables allow you to do some pretty neat things such as using a table to call a specific function table() and even more, than what you would be able to do with just a regular table. The reply above me has a pretty good topic on metatables however, and I’m not to explain every single thing you can do with metatables in a single reply (That would take ages!).

1 Like