Is a module-based storage better than a physical storage?

I currently store a lot of my variables (gamepasses, animations, developer products etc) like so:
image


However, I have seen other developers store their variables in modules like so:
image

local gamepasses = {
	["Bonus Dances"] = 4582008;
	["Cyborg Guest"] = 4582097;
	["DJ] = 4814430";
	["Macho Soldier"] = 4582096;
	["Super Guest"] = 4582093;
	["TitleColours"] = 4577488;
	["VIP"] = 4577505;
}

return gamepasses

Is their an advantage using one method over the other, and if so why?

1 Like

It’s up to personal preference, really. I go both ways a lot.

2 Likes

I generally use physical storage for data both the server and client share. The server automatically replicates the values of things to clients, so it removes the need to use remotes to replicate those changes.

You’ll still have to use remotes for client to server though.

2 Likes

It’s up to what works best for you. The only two advantages I see to the module-based approach are slightly less overhead and that it is more searchable. Instead of having to navigate to a given folder you can search through all the code in your game using the find dialog to quickly look things up.

3 Likes

I heard from somewhere (not sure how true it is), that it is safer to save data in modules, like the second example. Not too sure if it matters or not. :man_shrugging:

@Kampfkarren @dogwarrior24 @TheGamer101

Thank you all for the feedback. I think I’ll stick with physical storage for now as it’s not worth the time converting to modules but I think for the future I’ll start using modules - both for the reasons TheGamer101 pointed out and because it’s a bit easier to edit long descriptions (e.g. for quests).

As long as you store your important data, scripts, items etc on the server then your work will be safe - modules wouldn’t make a difference in this situation. Most developers store values like gamepasses, animation IDs, etc in ReplicatedStorage so they’re easy to view for both client and server.

Instances will Always take up more Memory than Code Stored inside a Script.


My Mentor said

Objects use a lot more memory than a hashed table

You have to remember

Some players are using a toaster

so they don’t have much free memory

You should always try to keep memory down


Think of Storing Money as an IntValue in every Player, if your Server has 100 People that’s 100 of them right? and if it’s not inside Leaderstat for the Leaderbroad then you are wasting a lot of memory.

In other words it’s better to not show the Client (and Server) what they don’t have to see

2 Likes

That’s a good point, especially as you mentioned for things like datastores, but it shouldn’t be so much a worry in this case as I’m only storing a small, set amount of variables.

For a few things like Money and EXP it’s not problematic but what if you wanted to Store Hundreds of things?

That’s a Disaster.

You might say I’m over exaggerating

well

what if you wanted to store

Monster1Killed = 0
.
.
.
Monster100Killed = 0

and if you had a pet game like Pet Simulator

you wouldn’t want to store

Pet1.Level = 1
Pet1.Speed = 5
.
.
.

I guess you get the point now.

I also use Instances to store stuff in my game a little bit but I might change that.

You (or your “mentor”) wildly overestimate how much a basic Value instance takes in memory. It’s miniscule compared to everything else. Also, the parent of the Value doesn’t matter, leaderstats or not it’s still the same, very small amount of memory.

9 Likes

For datastores I store my values in a module, but in this case I’m only using a small amount of static values which would take up hardly any storage.

Up to preference, but I personally would use a module over values when it comes to the system your referenced in the OP, simply because it leaves me with more options.

["Pass1"] = {Id = -1, Activation = function(args) end}