Basically, I want to use a metatable for every button
It wont be for every button in the game, but I’ve been using OOP for a lot of things and I’m really liking it, the organization and whatnot.
I have a selection page, you select creatures, and it’ll load their stats, price, icons, if you own it, etc etc, I wanted to know if using OOP/Metatables for every button here is a bad idea?
I think it’ll be easier to code having methods like that and easy destroy/cleanups when the frame is exited.
Really just wondering if its bad for performance to do this, once the frame is closed all the metatables will be removed/destroyed/deleted, and created again upon opening the frame.
I want to note I don’t entirely care if it’s .000002ms faster to not use them, I more so want to know if this will cause any noticable or major performance issues, and if it should be avoided. It is nice to know everything about them, but my main goal/focus is, can I use them.
I mean, it won’t be a major performance impact but may have to do some cleanup depending on what is going to be inside the metatable, since you don’t want memory leaks. Metatables are tables, so any connections in the metatables, other gui elements refrenced inside of it or custom properties for the button may all have to be cleaned up.
I do believe you can set a metatable to nil but I’m unsure about that.
tl;dr It’s not encouraged but no it shouldn’t have a massive impact but make sure its especially being done on the client not the server. (now destroying and creating guis that does have a performance impact, so watch out for that)
Okay thank you. I didn’t know about the creating and destroying gui’s effecting anything, so I may create templates and just store them somewhere, and assign them to metatable in the future.
A good reason for metatables is also, imo easier to cleanup all of the connections, I store connections, threads, objects, etc, and :Destroy() cleans them all up