How to use DataStore2 - Data Store caching and data loss prevention

I can’t use this for some reason, I keep getting errors.
First, I tried using String values, and this error appeared (don’t mind the module name, I made all of my scripts with these “encrypted” names):
Cattura
The line of code I used here is a simple dataHairs:Set(hairsID.Value)

Then, I had to do a LOT of work to take ALL the string values and make them into Int values and, guess what, this error appeared:
Cattura

I wonder what I’m doing wrong. I looked up at a couple of tutorials online and they seem to work.

Edit: Just noticed the second error appears when I use String Values too, and forgot to mention it appears when the player leaves the game, while the first error appears when the player clicks the button to save.

1 Like

The error you are getting is pretty explicit. Don’t use :GetTable if the default value isn’t a table.

1 Like

Hey, i’ve ran into some difficulties using this module, please take a look at the topic i posted it would help a ton. DataStore2 Help - #6 by AmbitiousAmateur

1 Like

I wasn’t using “:GetTable” but the normal “:Get”. I found out the error is that the FIRST element in the DSS2.Combine is saved as table instead of a value, for some weird reason. I wasn’t understanding what was the problem cause ALL values were saving except the first one. So I just made a “glitchedTable” value as the first element and put everything after that, and everything saved as value, except the first one that saved as a table. Thanks anyways, I guess?

2 Likes

I have problem with data clearing after i setting data to nil it wont save it. its saving only edited data. and new created one.

1 Like

After my own system backfired miserably, I will be migrating Crazy Stairs to DataStore2. Thank you so much for this module mate.
Edit: Update is now live, I will post feedback soon.

1 Like

I have this while loop that increments a datastore up 1 every 60 seconds, but when I join the game it works for me however when someone joins it will work for them and not me, anybody knows what’s the problem?

1 Like

Is a data history possible for this? Since I have a loop that occurs every 60 seconds, would it be wise to fit all the data such as coinStore or pointsStore into an array? and that should keep history of their data in case i ever need to roll back for whatever reason or there a cleaner way to achieve this?

1 Like

There is no built in functionality for this–DataStore2’s API is all in the documentation.

1 Like

Two days after launch and no issues whatsoever. Right now I’m reaching 100 concurrent players. Thank you very much for this, there is no telling how long it would take me to write something similar to this. As a side note, I have developed my own migration system, so I can use the default method of saving. I had plenty of players in beta.

So far so good, and it does not seem like it is about to fail. I would have to delay launch if I did not discover this. You saved me TONS of work. Thanks once more.

@Kampfkarren I keep having issues with :Set(), trying to set data but its not persisting. when setting a string I can immediately retrieve it, but when restarting the game the data is nil.

This is the perfect example of whats happening in multiple places around the app:

Save happens automatically when stopping game, so by doing it manually I managed to replicate the problem in a single script. I’m using default settings, no funny business, normally I have no issues but then all of a sudden in some scripts I get this behavior.

I really wanna use DataStore2 instead of traditional storage, anyone that has the answer to this please contact me. I’ll give 50 USD to anyone that can resolve this. Paypal only.

to fix this you need to get the value of the datastore and there you can set it if its a table then

use

local Tbl = SomeDataStore("SomeName", player)
local OrderedTbl = Tbl:GetTable({})

OrderedTbl:Set({"lol"})

-- also if you have a default table to save then insert strings inside the table!

just helping we dont need any money tho :slight_smile:

This doesn’t solve nor explains the behaviour.

Changing the key works, but WHY? once its a table you can never change types? I tried running @Kampfkarren script and still my key its ruined?
image

1 Like

can you change your master key bc it will reset any data involved with your previous one

This makes it work the first time only (LOL?). After .Save I do get the value! but restarting the game, running :get() function returns nil, and running the same script again with no changes now returns nil after save… whats with this behaviour? how is it that I change either the key or the masterkey for it to work only once… and then never work again?

how are u setting the values of the table tho?

this is the only place where the values are set, no other place is using :set() for that particular store. I’m noticing some people having similar issues when using Datastore2 in remote events, I might be wrong tho.

Edit: But still doesn’t explain the behavior
Edit: My offer still stands

i set my table when a remote event fires try that and see if it works

Thats exactly what im doing, if you wanna try other stuff add me in roblox and lets talk.

@FerbZides Line 11 sets the value to “Hello” what do you mean “i never see you set any value idk what you are doing in that piece of code”

i never see you set any value idk what you are doing in that piece of code