Heya, still fairly new to scripting but have already coded a fair bit for my game. Now I'm just wanting to use OOP practices after my FYP page absolutely blew up with it. I've done a fair bit of research when it comes to OOP in Roblox, but honestly...nothing is useful. Here's some more details to my dilemma.
I've already learned OOP in university, and have used it comfortably well in Python and Java. So much so, if I'm working in a multi-paradigm language like Python, I always opt for OOP. That means I know: Classes, Object instances, attributes, class methods, constructors etc. I also know certain basic level concepts like Inheritance, Polymorphism, Encapsulation etc.
The problem however, is I don't know how to use it in the context of Roblox (and game design in general), specifically how to use it practically. It's even more difficult since Lua is functional by design, and only provides the mechanisms for OOP, which makes some implementations unnecessarily more complex and unintuitive. And most of the videos and articles I've watched and read don't really touch on this, since they're so focused on teaching the absolute basics of OOP of which I already know.
So here's my question
Currently, I have a non functional flashlight model mesh. It's just the model of a basic flashlight i grabbed from the asset store, and removed whatever script (since I want to add my own functionality) it had.
So how do I add basic functionality to my flashlight model (on and off) using OOP? How do I structure my files accordingly?
I've tried (and failed) to create classes (one item class, and a flashlight that inherits from the item class). But I don't understand how do I actually take my class, and apply it to my model, so it functions as an Object. So if I've created a flashlight class, how do I take my class, and somehow apply it to my flashlight model so the flashlight can actually turn on and off, using OOP?
One final thing: I'm not really asking for you to write a script for me or something like that. If i didn't want to use OOP, I could code this thing in a flash, easy peasy. Since I'm more interested in learning as opposed to having the final result, I'd just like an explanation of how to approach this.
Consequently, if you decide to answer or help me with this, know that unless you give me a super detailed answer or explanation (you don't have to, but i welcome it), I will probably annoy the hell out of you with follow up questions, so just be warned :)


** You are now Level 4! **
