How to handle 2 similar yet diffirent systems?

I have a game with 2 main places: Lobby and Round.
They both have building plot. But:
Lobby: Plot is local, exists on client only, but actions should be performed on server and replicated back. The lobby plot is placed at the same spot for everyone and not replicated between 2 diffirent players.
image
(And all 16 player’s plots are placed here)
Round: Plot is on server, actions performed on server. Each plot is placed individually.


(Assume that all 6 plots here are just from noob players, they can be diffirent)

The problem I face is that I have almost identical systems, yet which have major diffirence in such replication. It’s really big barrier for using single module script for both. (I mean I can’t just use 1 same module script to handle both places without any modifications)

Just for example:
Smelter - thing which can accept ores and fuel. They are storen inside internally, with script values, like self.Fuel, self.MeltingOres, self.Melted. Also it can output physical object - ingot, which later can be picked up.
On Round everything is simple - ores and fuel added from server values, and server outputs ingot.
But Lobby must use diffirent approach. Ores and fuel will be still hosted on server, because they are internal script values, but ingot is physical object - it must be created on client, because it will glitch otherwise - non-existant smelter for server, while ingot is serversided, and some other issues, which I won’t describe cuz too many.

So, I came into conclusion that I need somehow separate 2 systems, or at least try to branch them. Like if IsServer then Load123, else Load 245 end

But this system is really hard to maintain, so, maybe there’s any better approach possible?

You could try and split it at the event level. I.e. have a BindableEvent for things that are clientside, then if they need to be moved serverside you just switch it wil a RemoteEvent?

1 Like

The problem is not bindables/remotes themselves, but structure of how it’s done. Entire system does same thing, but internal processes differ enough to be trouble.

I wish I could give you better advice but I’m frequently facing the same problem.

1 Like

I have finished making it. Made somewhat acceptable setup:

  1. Subdivision made by Server/Client
  2. Lobby/Round utilize same ModuleScript instance
  3. Lobby/Round themselves are separated in module by single big if block

Hopefully this kept code readable, and updating it won’t be that hard as I did before with masking everything into one piece of code with tons of ifs


If you are interested in what I were trying to do (smelter is clientsided object, ingot from it too)