In my game, I want to store per-player data, for example, how many kills they have, how many items they collected, etc. (Not permanently, just so scripts can work with it.) The way I do this now is that I have a Script detect when a new player joins, and then it creates a Folder under the Player objects and fills it with IntValues and so on. This works pretty well, and is easy to debug because you can see the data without having to print it, but I was wondering if storing data in global (_G. type things) dictionaries would be better. For example, instead of giving each player an IntValue called "kills" and then doing things with that, I would have a global dictionary (_G.playerKills = {} or something like that), and then I would store data using the player's name. So if I wanted to store 10 kills for player named "TestPlayer", I would do
_G.playerKills[player.Name] = _G.playerKills[player.Name] + 10 --'player' is the "TestPlayer" player object
So, what is more efficient? Which method is neater? Which one would you use? Anything helps :D thx

5 comments
It's actually not advised to use Globals. I can't elaborate on technical reasons, from my understanding they may prove to be inefficient compared to other methods and less secure. However, might I just suggest using multi-dimensional arrays and withholding data that way?
Multi-dimensional arrays? Like, a list inside a list? I do that sometimes, but that's for saving player data into a DataStore. Here, I need to save some data which is frequently changed and can be accessed by several Scripts and LocalScripts at any time, preferably without having to call a RemoteFunction every time.
I use a module script in the server storage. It is not replicated to clients, so has an extra layer of security. On top of that all data is in the same place and I can easily decide what (if anything) needs to be saved in datastores. Other scripts access that data through functions. I can provide you some code if you interested.
What exactly do you mean? So like you require the ModuleScript and it returns some values? I'm a bit confused lol. I need LocalScripts to be able to access all that data, and I think it is pretty secure anyways as even if the client changes the variables, it makes no difference to the server or anything.
ServerStorage and ServerScriptStorage are not replicated to clients. That means if you keep data elswhere on server it still cannot be changed by clients other than remote events and functions. Exploiters however can see this data, even if it is some other player data. They have no access whatsoever to server storage though.