Feedback on my first attempt at OOP

Over the past day or two, I have been investing my time into learning OOP, as the next project that I am planning on working on will be very complex, and I need to learn how to structure my game well.

I have created a small project in which when the player joins a game, a spaceship is created for them using what I hope is an object orientated approach. The project uses Composition instead of Inheritance, as I have heard that Composition is better for this kind of thing. Here is the github repo of the project:

(The code is in the ‘src’ folder, as I am using VSCode + Rojo - you can view where each folder’s code is stored in-game by viewing default.project.json)

I am looking for feedback about what I have done well, and what I could have done better, so basically just any feedback is appreicated!


Your attempt at OOP is very good. One thing about OOP, only use it if your making a lot of something. (eg. TDS games) You don’t need to make it for the thrusters, combine it with your ship module. Overall, keep on going with this!

1 Like

Thanks for the response! There are going to be more things similar to the thrusters class (e.g. shield generators and cargo racks), which is why I put it in it’s own seperate script, because with the amount of ship modules there are going to be, the main script would get very long having them all in it.


One question I have is: let's say I want the ship to move forwards when W is pressed, how should I go about doing this? Seeing as key presses are detected on the client, I would check when the player is holding 'W' in a RenderStepped function, but then what?

I could create a method in the thrusters class called 'Move()' or something, but how would I pass that method to the client, as metatables don't get sent with tables in remote events. Also, wouldn't doing this create lag, as I would be calling the method every frame?

BTW I’m not asking you to write the code for me, I would just like a pointer in the right direction. Do I even need to use OOP for this, should I just put the move code inside the RenderStepped function?

(Edit: I have now updated the repo with some changes to ship module creation, feel free to check them out! I am a little bit unsure if I’ve gone overboard with all the different scripts for different module types, so any feedback on that would be great!)

1 Like

Use context action service, it’s fast, simple, and quite useful. You already have a ship handler for the client so add the key binds. Just unbind it when the player leaves the ship.

Using OOP would be redundant ( unless you’re making it in the client ship module ). Have it in the client script.

No, this would be very slow and laggy. CAS will take care of that.

Yes, you could. You just have to fit it in the bind.
Don’t put the method in the ship unless you want messy code. Yes it would create lag doing it every frame. This is because you’re always checking for a keycode which is unnecessary.


Use context action service in the client ShipHandler script to check if to move.


Some feedback

The modules are now nice, you have a module for important parts of your code. I may ask, why do you use BodyMovers. They are old and should be used for games like RetroStudio.

Am I to understand that I should use a remote function from server > client to send the ship with the metatable? And how does this differ to just using a Remote Event? I thought Server>Client remote functions weren’t used as it could leave the server hanging?


While yes, I said “if you want”.

RemoteEvents do not return anything while RemoteFunctions do return. RemoteEvents are used for simple actions from client to server or server to client.

From my knowledge, yes, this could and will happen. That’s why I only talked about it for one sentence.

If you do really want to do this route, then yes. I never tried it so my bad. :fearful:

1 Like

I don’t use body movers, I use AlignOrientation and LinearVelocity (unless that’s what you meant by body movers), I have their variables named gyro and velocity for simplicity’s sake.

1 Like

Oh sorry, I must have misunderstood what you meant in your last paragraph. Do you mind explaining to me what you meant?

1 Like

I meant that if you really and have to do or want to, then this is what you would do. Sorry for that part :fearful:, I will edit it out.

1 Like

I am currently doing exactly that: using UserInputService:IsKeyDown() in a RenderStepped function to check when I should yaw and move the ship forwards, and so far there are 0 performance issues, and I am using a rubbish laptop, so I don’t think there is really any problem using RunService to detect key presses.

1 Like

UIS is not CAS, but you can do what you want.

1 Like

I was referring to this statement

To which u replied

However, thank you so much for the help!

1 Like