Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Can someone explain why you should use metatables?

I understand what they do to a certain extent. But I don't see any reason to use them. Can someone tell me anything you would have to use them for?

1 comment

0

Onion...

1 answer

I use metatables to do object-oriented programming. Basically, I just use them to store information. Here is a tutorial: https://devforum.roblox.com/t/all-about-object-oriented-programming/8585

Currently, I've created a 'Sword' object for a game I am creating; using OOP allows me to quickly create a variety of swords because all swords inherit the 'Sword' object, or class, but obviously have different damages and abilities. For example, a Darkheart is a sword, but it isn't the same as a LinkedSword.

I'm sure metatables have other neat uses, but this has been my favorite so far.

This discussion is preserved as it was. New answers, comments, and votes are closed.