Are we supposed to combine the DataStore in PlayerAdded or just once outside any functions?
Just once works, as long as it’s called before you actually use the data store. I like to put them at the beginning of the script.
Hi @Kampfkarren.
I am having some problems with saving a Dictionary in DataStore2.
Could you please look at this post:
How to save Dictionary using DataStore2? - #7 by Oficcer_F
Thank you very much, I would really appreciate it if you would take time to help me.
I imagene many other people have issues with this also.
Sincerely.
Since there is essentially no data loss with this, is it still necessary for me to do :SetBackup()?
DataStore2 uses Roblox data stores internally. Roblox data stores go down. Yes.
How should I implement :SetBack()? Am I just able to throw :SetBackup(5) in my script and the module will take care of it? Or are there more steps that I need to do to utilize it properly? I don’t fully understand this part so I’m not entirely sure what to do.
If you do :SetBackup(5)
, then if the data store fails to retrieve itself 5 times it will just use whatever the default value you gave it is. Data will then not save so nothing gets overwritten.
As a developer, you need to make sure the player knows they’re on a backup (with :IsBackup()
). Some developers choose to let players continue playing while telling them their data won’t save, others choose to simply kick players. It’s up to you what you do, as long as you do something.
So if a player were to join and their data didn’t load due to an error on Roblox’s end, I could do :SetBackup(5) and then they would not be playing on data that would be saved when they leave? Then if I were to have a script that would kick the player if :IsBack() returned true, and then they rejoined, they would be back on their data that was there before they joined and the data failure occurred. Am I understanding this correctly?
If you call :SetBackup and DataStore2 can’t load their data, it won’t save at all. You wouldn’t want it too–you don’t have their data.
So SetBackup() is like a safe guard against saving default data onto a player whose data wouldn’t load? And then when they rejoin, their data will be back to before the data failure occured? Sorry for asking so many questions, I just wanna make sure I am understanding this correctly.
What you said is what backups are for, yes.
Sorry I have one more question, if I am using DataStore2.Combine, do I still use :SetBackup() for each individual DataStore? Or is there something else I have to do?
Also, would I place the :SetBack() before or after the .Combine? Or does it not matter?
You should only have to call :SetBackup once, but there’s no harm in doing it multiple times.
There’s no built in way to get previous data saves (besides the most recent one), right? Would i have to edit the module for that?
No, somewhat intentionally. The data loss prevention is so that setting/getting does not have data loss attached to it, not for something if you screw up. Also there’s no great way to write a generic API for it. You would have to modify the module.
I see. I always like to have the option to revert data available for my admins, but i’ll re-evaluate how needed that is and try editing the module if necessary.
That’s a fair use case, I think. There may or may not be an issue on the GitHub page for this but if there isn’t please make one.
Is there any way to save datastore without the instance of a player?
4 posts were merged out for being off-topic
Please refer to the thread linked below