Would it be ok to give each player their own data store script?

currently I have a functional saving system that saves the players building.
right now its only one script, and it loads/saves when the player leaves.
but I want to create save slots that will allow the player to save multiple buildings.

I started to create a gui wit save slots, but I have a few questions on this.
I want to give each player their own datastore script, this would allow the player to save and load at their own discretion. if I just used one script, I feel like their would be too much traffic when lots of players want to save and load constantly. would it be bad to have more than one datastore script? would save slots be an exception?

Why would it be bad? Maybe you should test and see if it works.

I only ask because in a previous post they mentioned I should only have one script that handles datastores.

Only downside to everyone having their own is Roblox’s limitations on datastores in which you can’t request the same key tons. Personally just having one big handler is probably better and easier seeming as its just as secure and allows for cross-player data manipulation by the server easily.

Its to your discretion and the limitations of the site :man_shrugging:

I had one for each player once and that just ended up with my datastore backing up requests and having a queue - not great.

Good luck.

1 Like

considering that Im adding slots, would it help to add load/saving cooldowns?

Well if you think about it you only can ever load one slot at a time, and each slot isn’t going to take microseconds to load. You’ll wait a good 3-5 seconds before you can do it again.

Also your going to be loading the datastore on the server anyway so whats the harm of just having it as one big script and not having to call the datastore every time you want to do something. For me I call the datastore two times in a players entirety of playing my game: to save and to load.

when you save and load, do you have the script run a separate thread? (such as spawn)
If I were to do one single script, I would have a bindable event so the scripts in the players gui can interact with the datastore script, when the player requests to save for example, an event listening to this would spawn a new thread and run a function that saves the players data, should I go with this?

Well, to begin with your perfectly right to have a bindable event (or bindable function) so you can interact with your datastore. In the end this makes sure you don’t accidentally find your data is being written in twice with different values.

Roblox provides a :BindToClose() function so you can stall the user enough that you can do any data manipulation on them. You can also use PlayerRemoving to be a trigger to save the current data. So yes, have a save function if you wish - depends on how much you trust your datastore to save. I only save at the end of the game session and haven’t really experienced much problems, the server can in strenuous situations fail however so frequent saving is required for most actual games. Group games don’t really matter though as its a closed community :laughing:

How you capture it is your own design choice with four options:

  • Save at end,
  • Save at time intervals ,
  • Save at key events,
  • User manual save.

Good luck.

1 Like