Creating a class that can easily interact with the server and the client?

This post was written in first place in French, and has been translated by Google Traduction.

I’m trying to adopt an object-oriented programming style on Roblox, because I find that all my lines of code are clear and organized.

Only, I have a problem when I try to make interact a class that I invent with the server and the player at the same time.

To put it simply, I have a jetpack. I create it from the server with constants such as speed … but the jetpack also needs to be visible by the client since it will trigger when the player presses on a specific entry (F for example).

So, I do not really know what to do, how to organize scripts to achieve it. I thought of putting it in the ReplicatedStorage, for example, so that the module that makes the Jetpack class could be visible to the client and the server, but I was told that it was a bad practice because the exploiters could access the module and do malicious things.

I really do not know what to do, so if you have an idea about the approach I should follow in order to create a class accessible to the client and the server.

1 Like

This is not true as you’re going to need something the client can see for user control. However, even by putting the module in ReplicatedStorage, the client still cannot commute to the server thru that module. you need to setup RemoteEvents for your keybinds and user control.

3 Likes

Hello!

I just want you to be aware of this:

It probably will not impact your development, but then again you are using metatables so better safer than sorry.

I’m happy you found your solution!

2 Likes