I’m not sure that I understand how you’re storing this data. I don’t know what “store all of the variables … as a metatable” means.
Could you post an example of how you’re doing this? Could you also elaborate on what “attached to the player” means?
Generally, tables store data, and metatables store behavior. The metatable won’t change, but the table will. Since the table has a metatable, they work together to give you data + behavior.
Neither tables nor metatables give you any sort of automagic server → client syncing capabilities. You’ll have to handle that yourself with Remote or Value objects. One particular thing to note is that metatables do not get transferred through Remotes. This should be fine, however, since metatables should be static. You should be able to call setmetatable(data, behaviorMetatable)
to get a metatable set up for the data table that you receive.
I can see a very good use of ModuleScripts and metatables here. By combining the two, you can get an “object” that automatically gets/sets underlying Value objects in a folder. This simplifies your code in a lot of places, since the module + metatable can take care of a lot of the work. The module + metatable can handle creating the Value objects, ensuring the right Value object is made for the value type being set, and possibly serializing/deserializing data.
Rather than use BindableFunctions, one can use modules and call the functions directly. You can have tables “attached” to instances and do something like Module.getAttached(instance)
to get the relevant table. If this table has a metatable, you can then do things like Module.getAttached(player):damage(50)
to damage the player.
In this case, the table contains a reference to the player, and the metatable contains the damage
method in its __index
. The table is describing the data (player), and the metatable is describing the behavior (how to damage the player).
I definitely agree. I follow object-oriented programming with my table/metatable organization for the most part, so it’s really easy for me to add on to. On the other hand, it’s taken me a lot of time to get a system that I like and that I’m comfortable with.
If you want to complete your RPG, use what you know and are familiar with.
If you want to learn metatables, or anything new, mess around with it on a project you don’t mind staying uncomplete or becoming a mess internally. Once you have something you know works and is structured well enough, start using it in projects you care about.