Question about modular game architecture

I’m working on a game where there are multiple characters, each with its own characteristics and set of abilities. I’ve gotten to the point where my confusing code is making it harder to add new characters, so I decided to rewrite it. More specifically, I’m using @Crazyman32’s Aero Framework for the rewrite.

I’m planning to split game data and character-specific code in multiple modules. I thought each character should have its own ModuleScript, but both client and server need to access it, and I wouldn’t want exploiters/stealers snooping around in server-sided code, which means splitting it in 2 modules already: one in ReplicatedStorage for data and client-sided code, and another in ServerStorage for server-sided code only. But here’s my dilemma: should shared data and client-sided code for a character really be in the same module? After all, the server doesn’t need that code, and it might increase complexity since I need to make sure the server doesn’t try to access anything exclusive to clients. On the other hand, splitting a single character’s data/code in 3 modules seems a bit excessive to me.

afaik, both the client and the server get a different copy of the module script so the exploiters cannot exploit the copy given to the server. If the server only needs access to it i would still put it in ServerScriptService, If the both need it then put in in ReplicatedStorage.

Wait but what if the module is in replicated storage?

If the module is in ReplicatedStorage both the server and the client will receive separate copies AFAIK so neither can interact with each other unless it is through remotes.

Wait so if I have a module handling damage for both the client and the server the client wont be able to edit the server copy?

AFAIK yes, i use modules in ReplicatedStorage and i believe this is the case.

So lets say have a module that stores mission names and I need the client and the server to acess them, so the client wont be able to change the names of the missions I have?
@ahmedluai22 Sorry for all these questions but I use modules alot

Okay, so thank you for making your post clear and informative.

First off, the fact you dont want serversided code being exposed, leaves us with an approach of splitting it into two modules.

As you said, first module will be the server module, second one will be the second module. Now, since this will also serve the purpose of being shared data, and client code, we will use RunService:IsClient().

Okay, since you seem smart, I’ll leave this bit up to you.

(Server Module)

local CharModule = {}


-- do server stuff --


return CharModule

(Shared/Client)

local CharModule = {}
local RunS = game:GetService("RunService")

-- do shared stuff --

if RunS:IsClient() then
   -- do client stuff --
end

return CharModule

There you go, another thing to note is - dont feel bad about using 3 modules, popular games like Garry’s Mod use 3 modules for basically what you’re trying to do: (Server - Shared - Client)

1 Like

They would be able to change it on their own copy but, not for the copy of the server one. Here is a useful solution which i found explains it well. How do I use ModuleScripts?

1 Like

OP meant exploiters snooping around in his code, not exploiting the caching behavior of modules, by the way.

1 Like

Oh i see, My bad i misinterpreted the question. In that case, yes the exploiters can see the code inside of your module scripts (If they are in a place the client can access)

1 Like

Ok, I think I’ll go with the 3 modules approach since that seems more logical and organized to me.

1 Like