Is it okay to use more than one datastore?

What I’m afraid of is if using more than one datastore will cause the players to lose their data. Is this true?

Heres what I’m doing:

  • The “ModBans” datastore is just an updateasync boolvalue just to make sure if you’re banned or not.

  • The “Points” datastore is just an points datastore that loads and saves your points.

  • Now, I can’t keep the “Leaderboard” datastore in the same datastore as Points, because it is an ordereddatastore so I can get the player with the highest amount of points

3 Likes

Short answer: Yes

Long answer: Most people will disagree with this and say you have to use a table and save that table to a single datastore, this method is more efficent, but if you are new to datastores or tables, this can be complicated and somewhat useless. Any code is useless if you don’t understand it. So it does not hurt anything(Beside maybe a little bit more work for the server) to use multiple datastores.

7 Likes

But I’m a developer with an constant flow of players, will that affect data corruption?

No it shouldn’t, unless you use like 10 DataStores.

It all depends how often you call GetAsync and SetAsync, not how many DataStores. If you do 2 calls per minute per player, you’d be fine by a long mile. If you do 10 calls per minute, you may run into problems.

Sometimes it is far easier to just create another DataStore than edit a table, and sometimes it’s even cheaper to do so. It depends on your usage case. Generally speaking, it’s best to batch things together, like doing all leaderstats in one datastore.

2 Likes

I personally use tables with dictionaries to store data which works well for me, however if you make sure to wrap the data store request in a pcall and deal with the error efficiently you should have no problem with players losing there data.

2 Likes

Thanks, your post helped me too, I just didn’t want to run into problems with data.

@12904

Excuse me, what? Saving tables to DataStores is not a complicated or useless practice. Please do not make unsubstantiated comments that don’t contribute to solving a problem.

Your second “long answer” also contradicts your first answer. Why would you say that nothing is “hurt”, while also saying that data will be lost? That doesn’t make any sense at all. Saying “nothing is hurt” isn’t even a sufficient enough reason to support or condemn a practice.


While it doesn’t necessarily matter how many DataStores you have, you should try getting into the habit of consolidating data based on type (ModData and Points could be consolidated into a single DataStore related to player data, while the Leaderboard ODS can be left as its own thing) so you avoid any potential issues and conflictions with data.

Your problem is akin to the one that was linked by OverHash, which is calling DataStore twice. You never know when you may need to expand your saved data beyond points in the future and if you have a constant flow of players, this could potentially be problematic. This is why I personally would save a table, so that you can poll from a DataStore once per join and then operate with that data for the rest of the session however necessary.

On the other hand, so long as you are only performing DataStore operations where necessary and staying within budget, then I can’t really protest against the practice of using multiple stores. You really shouldn’t though. For a small project, there may not be much issue, but it can expand to a bigger issue depending on the project or traffic being handled.

4 Likes