Are module scripts an effective way of storing player data

currently i’m making a game and the plan is to save and update player information and progress in the game via a module script, but is it possible to change values in a modules script or would it be better for me to create my own folder and organize everything via string, int, and number values?

I always go with tables for storing player data, IMO there’s no good reason to use IntValues, StringValues, etc., for that purpose at least.

You can’t “use a modulescript for storing data” though if that’s what you mean, you’ll need to use data stores for that. You can make a modulescript that deals with storing player data and makes it easy to use in other scripts.

1 Like

yeah i mean using datastores and stuff, I was just gonna make a table in a module script and using another script to handle the saving. Question tho, do you use module scripts to store your table or do you just use local scripts/scripts. I was gonna have all this info on the game and player progress etc, and change it using a script to a module script. But is that how it works? like can I have an empty module script with only a table and then change stuff from the table through a local script? I am new to all this scripting stuff so any feedback is extremely useful here.

1 Like

Yes, but actually no. It’s bad practice to allow LocalScripts to control anything that’s important for the game play, except in cases where it’s not possible to send a request to the server to do the thing on the behalf of the client, after doing all the necessary checks to make sure the client isn’t being controlled by a cheater to send illegitimate requests. An example where it’s sometimes not possible to do everything on the server is hit detection in a shooter game. But if you’re talking about e.g. storing how much money a player has, the server should always be the final authority. You can totally do that from a LocalScript but it’s a bad idea.

This is completely fine and exactly how I’d do it. I’d create a ModuleScript that returns a table with the default player data that a player is supposed to have when they join the game for the first time, and any saves overwrite that default table. E.g.

-- DefaultPlayerData ModuleScript
return {
    kills = 0,
    deaths = 0,
    money = 500,
    completed_quests = {}, --empty because none are completed
    inventory = { 10, 10, 13 }, --item IDs, players start with 2 coal and 1 stone (or whatever)

You’re most likely going to want to send some of this data from the server to one or more clients, which you can do using RemoteEvents.


it would probably be better to just use a table in your main script with a bindablefunction to get and set objects in the table from different scripts. if you are planning on allowing the client access to the server, you can also check the environment of the calling script for a key of some kind

For the time that the player is connected to the game (without teleporting out of it of course). This remains to be a very effective way to store data. But the moment the player disconnects from the server, everything stored inside a module script will get erased.

That is of course, if it isn’t saved into a datastore first.

awesome dude! that’s exactly what I needed actually. I guess I probably should’ve known that doing it in a local script was bad cause of exploiters, but good to know on the other hand. But if i’m not mistaken, server scripts can’t access scripts in the player, so I’m wondering where I would put my module script to give each player their own data. Sorry if theres a simple answer to this, you’ve already been extremely helpful to me!

1 Like