How to add specific methods per metatable class?

So I have a plot building project I’m working on; and there’s a few classes that don’t really go together but share similar functions.

For example: couches, paintings, any ‘stationary’ item has a :Move() function, but there are loose items that do not need this function. They’ll have a :Drag() function instead. However, both of these classes need a :Destroy function.

Is it possible for me to have a metatable class object (example: the couch), while only inheriting functions that I choose per class?

Like in one module class object, it’s a couch. The couch needs the :Move() function and :Destroy() function. However, a loose item, like a can of soda, has :Drag and :Destroy().

Now there’s tons of different stationary objects vs loose objects. For example, theres not only just a couch, but also a painting, rug, etc. All of these would need both the :Move and :Destroy functions, and there’s also a ton of loose items, like can of soda and turkey leg, which need the :Drag and :Destroy functions.

The reason I can’t just clone a :Destory() function into every single class is because there’s dozens of classes, and if this destroy function needed to be updated it would be a heavy pain to go through them all.

Also, I can’t use SuperClasses because there are some objects, for example, ‘Ultimate Painting’ that I don’t want to have a move function. Using a SuperClass sounded fine until this, and I don’t want to have checks in place to stop Ultimate Painting from running the move function, I would rather just have the move function not exist for it at all.


So my question is, can I have a module ‘constructor’ script (a module with .New() and it grabs all necessary components) that inherits multiple functions that I choose?

I tried adding a metatable to another metatable, but it didn’t work. I guess you can’t assign multiple metatables to one table.

1 Like