Like what do they do and how do they work?
I've tried reading some posts about them but I have trouble understanding them.
Any help is appreciated.
the wiki definition states “bla bla rocket science 2/3=193” or something, idk.
in simple terms, they basically allow you to use player defined functions on a table.
you (the programmer) write functions and they are called when you try and use the table.
for example, say you had table A {5, 4, 9, 2} and table B {8, 1, 9, 0}
by defaulting, typing A+B into a script will cause an error. you cant add tables. how does that even work?
metatables allow you to add tables. how will they add, you ask? that is up to you. you can write it so that it adds everything in A to everything in B. you could make it so a new table is returned, with a random element from each A and B. really, you can do anything.
also, doing A[5] causes an error because A only has 4 elements. with a properly written metatable function, you could make it so calling A[5] actually does something specific.
a metatable is a table itself. you attach it to a table, using syntax.
setmetatable(x, {})
i wont add code because tbh I dont know the syntax. I am newbie developer, so I've never used them. tbh I dont even see how they’re useful. but thats basically what they do. after I had a pretty clear idea of what they were, I didnt bother trying to learn them, at least yet.
hope this answer was clear and concise :)
edit: metamethods are the methods that you actually write. doing A+B would call the metamethod that you wrote, and do whatever you wrote it to do.
if you are new to roblox scripting, or programming in general, honestly i’d say dw about it rn lol
"Metatables allow tables to become more powerful than before. They are attached to data and contain values called metamethods. Metamethods are fired when a certain action is used with the datum that it is attached to."
https://developer.roblox.com/en-us/articles/Metatables