Using OOP in UI elements

Hi, I have recently started learning OOP to make my code neat and cleaner, but I have a question: How would I be able to use OOP for GUI handling?
Let’s say I have multiple buttons, and each one does something specific (fires an event, sends a notification, etc). How would I be able to make that work in OOP?
It’s my first time using OOP so I am glad for any answers.

to be honest, you shouldnt. OOP isn’t necessary here. if you want a custom “event” i would use Signal. if you want a ui framework, i would highly recommend Fusion (i personally use this, i find it more straightforward than react), or React-Lua,

2 Likes

There’s so many “gotcha” moments to be seen with OOP that really makes it unfeasible for the average scripter. I think it’s not worth the hassle and just adds more complexity to everything, which you may never be prepared for (things like memory management, serialization, typechecking, etc.)

If you still want to learn OOP, using it on UIs is… a questionable choice. UIs are already using OOP because it’s roblox instances in the roblox engine. OOP is more suited for things made from scratch, like new data structures you designed for your specific game. You’re better off learning it by doing those instead of adding an unnecessary wrapper to the UI system that barely accomplishes anything extra.

1 Like