Is it a good practise to store everything about server in one single module?

Hello developers! I’ve been developing game and I came to idea to store everything in one single module script something like this:

local ServerInfoModule = {}

local Data = {
	Players = {},
	Props = {},
	Bots = {},
}


function ServerInfoModule.RemoveData(key,val,group)
	Data[group][key]=val
end

function ServerInfoModule.AddData(key,val,group)
	Data[group][key] = val
end

function ServerInfoModule.GetData(group,key)
	return Data[group][key]
end

return ServerInfoModule

And my question is, is this a good practice to do this? Or maybe I should go differently about this task?

I personally woulnd’t do that due to complicated debugging, But creating a structure thats too spaced out can also cause issues.

I personally think its good to separate concerns and keep aspects of your game and its specific functions together. For example, DataModule:

local DataManager = {
playerData = {}
}

function DataManager:Save()
end

function DataManager.Load()
end

but if youre talking about 1 module for each the server and client that handles the entire games functionality (ie, a module script that has DataStore, AiHandler, QuestManager) all in one module, then that makes it harder to expand, debug, locate, isolate etc.

It’s best to just have multiple ModuleScripts, instead of pushing everything inside one singular module.

A ModuleScript is meant to hold functions that are common to other scripts. So, for example, if multiple scripts use a function that checks a player’s leaderstats, then place that function inside of a ModuleScript that fits best with that function. Such as a ModuleScript that handles player data.

Hi,

Nothing is wrong with this concept. If you are asking from a teamwork-oriented standpoint where you are working with multiple programmers, you would normally document via external software or keep specific tabs by simply adding helpful comments. An experienced coder can find any comments using the “Find All” function in Roblox Studio (Ctrl + Shift + F). As long as you keep helpful notes to help guide others, this method of storing data is very clear and to-the-point.

In fact, I would argue it’s easier for other programmers to add code to the game if all of the data is centralized in one module and is easy to track. Some people may argue with this, but it really comes down to preference.

If this is for an independent project and you are more concerned about the performance differences, you have nothing to worry about! Performance-wise, storing data in one table as opposed to multiple tables should have very little difference in performance (if any).