What would be better in this scenario?

Hello, I’m switching from a local script to a module script in my planes movement and I’d like to ask if there is any benefits of switching between the two

Currently, when the player enters a plane a localscript gets cloned into the players character and from there it is handled on the client, however for more organization and efficiency I wanted to make a “Client” script and whenever a player enters the plane it sends a remote event to the client script saying that a player entered the plane and the client then calls a module script which handles everything.

I’m looking for the better option and if there is any pros and cons of either of the two.

I had this same issue with my code for vehicles and mounts.
Originally I didn’t know the server could place client scripts in things, so I had the server send an event to a static client script, telling it to get the vehicle client script and clone that into the character.

Then I eventually did as you are, where the server clones and places the script in the character.

Eventually I used a module script, where once again, the server sends an event, that tells the client that they are riding a specific vehicle or mount, and the client just calls the module script.

However… with the release of script run context, allowing for client scripts to run outside of the player.Character, I was actually thinking of having the client script directly inside of the vehicle.
The server can set an attribute on the vehicle, saying if someone is controlling it, the client script checks for that attribute change, and can allow itself to be controlled by the player with the matching userid of that attribute.

So, just something to think about.

I personally feel like that would be the best way to go about it however I’m looking to see if there is any cons if I do implement this

I don’t think there are any cons to it. It was much the same as having the server simply put a script in the player character.

It only seemed to have pros, in that I didn’t have to move any scripts around, cloning and deleting, etc…
Also I made my module scripts in a way where if it was required on the server, it ran server code, and if on the client, it ran client code.
So the vehicle on the server, would require the same module (in replicated storage) that the client would also require, and each would run specific code.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.