How «safe» are data stores?

There are 6 second cooldowns on Get/Set/UpdateAsync. So how do games do this? If they have to wait 6 seconds, how can they save data on the server close even though it takes a minimum of 6 seconds every time they want to save data?

1 Like

This is just wrong. There have been no recorded instances of player loss in games that use Datastore2 with thousands of players. Using :SetAsync() also may lead to data loss.

To answer OP’s questions, you should absolutely use Datastore2, as it uses one of the best saving methods. Here’s a good tutorial on it, and you need help, just ask. Good luck!

8 Likes

alvin blox is a bad view on learning development, this official wiki is also shown to what I said: DataModel | Documentation - Roblox Creator Hub

in fact all datastore2 does is cram all the data together and use setasync

2 Likes

AlvinBlox’s tutorial was helpful, but you don’t need to use at, as there are other ways of learning it.

I’m not sure how that link proves your point. Datastore2 also uses BindToClose. Did you read this article? If you haven’t, you should. It would explain why your way isn’t a good way of saving data.

Even if Datastore2 did use SetAsync, your method would lose data, and Datastore2 will not. I don’t think I’ll be replying anymore as I have already repeated my point multiple times.

From where do you have the information from? Did you read code of the module to know all of this or is it just assumption?

E1: DataStore2 indeed uses only SetAsync, but it still is no problem since there is under 1% of reported failures in saving/retrieving data. I also experienced no lag whatsoever on a stress test I did once on the server.

This may be your opinion, but for others his videos can be useful.

Datastore2 saves your stats when you leave your game or when the games shutdown. As data said where did you get your information.

That’s because the 6-second buffer only applies to writing to the same key, not between write requests at all.

4 Likes

The entire point of DataStore2 is to avoid data loss. It saves new data without overwriting the old in order to be able to retrieve the old saves in case something goes wrong. Your point is invalid as it has no negative impact for the developers, it’s only an issue for Roblox as they need more storage, but that’s what they get for giving us no reliable servers or data loss management.

:SetAsync() can and will fail during high loads, the same goes for :GetAsync(). This is also why Roblox themselves discourage the use of :SetAsync() in favor of :UpdateAsync().

4 Likes

If you’re afraid of using DataStore2, you should use UpdateAsync() in place of SetAsync() which could lose data and not account for older data. DataStore2 is also a good alternative if you want to use that to save data as it keeps backups and could be used in case of an emergency.

You could implement your own custom throttling system.

This is incredibly incorrect. Please don’t make definitive statements about things that you clearly do not understand.

There are significant (and undocumented) issues with using DataStores the way the developer hub wants you to, and many of these issues start getting very pronounced when trading, teleportation between places or other variables are introduced to your game.

DataStore2’s usage of SetAsync instead of UpdateAsync makes perfect sense, as it is writing to a brand new key for each save instead of overriding data on a previous key.

There is so, so much that can (and has) gone wrong with DataStores. Storing all of your players’ precious data on a single key is negligent. A lot of what DataStore2 does is “not pretty”, but it’s there because it’s the best solution to definitively solve many of the issues that come up when you override DataStore keys.

@Oficcer_F you should see this thread about the issues with DataStores and why developers are resorting to crazy measures to get additional functionality/protection out of the feature:

https://devforum.roblox.com/t/datastores-are-too-complex-for-roblox-developers/299070

17 Likes

Thank you for your answer Andrew!

If I am correct, you are the «father» of DataStore2?

I will definetely now use DataStore2 and hopefully learn how to use it :blush:!

Big fan of you, and thank you for taking time to answer me!

And lastly, does DataStore2 work fine if I have 1 datastore for coins and gems and another one for weapons and skins?

So 2 DataStore2’s?

You really, really don’t want to be doing this. Generally you want all of your data for a player to be stored in the same place, or else you run a very high risk of players either buying something and not getting the item or buying something and not losing any money due to a datastore saving issue where only one successfully saves.

2 Likes

You can think of different data-stores(service:GetDataStore()) as different folders. Inside everyone of these folders there are keys pointing to a JSON formatted string. Now why would you store the gems and coins in one folder, all while keeping the weapon and skins in another?

Thanks for the clarification!

What would be the best way to make an «organized» data store with this?

I assume you must have all of the datas in the same folder…

How can I kind of «separate» these?

Is it possible to have a table inside a table :thinking:

Yep, you can have tables within tables within tables within tables

local table1 = {}
local table2 = {table1}
local table3 = {table2}

= {{{}}}

A popular way to store data like this is using dictionaries. For instance:

local playerData = {
	["Cash"] = 0;
	["Exp"] = 0;
	["Inventory"] = {};
	["Characters"] = {};
	}

Where playerData is the value to be saved to the datastore.

5 Likes

Thanks for the explanation! And the help I have recieved!

Now I am on a good track to make a DataStore(2)!

Hi berezaa! Sorry for bothering you again, (knowing you are busy) but I am wondering if you could help me with saving a dictionary in DataStore2?

If you could just tell me the functions and point me in the right direction, that would be great!

I would appreciate help beyond imagination!

Here is the question:

Hi, as I asked berezaa, do you know how to save these dictionaries in DataStore2?

Having a hard time finding out about that since there is no documentation about how to do that in the post nor on the internet :frowning:

I would truly appreciate an answer from you allthough I know you have a lot of work to do (considering you are a famous developer).

Here is the question:

Best regards.