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

Just changing the master key works.

2 Likes

Is there any other way resetting data than changing the key?

1 Like

There is not currently.

1 Like

I’m not sure what you’re asking. To combine data stores, right after requiring DataStore2 write:

DataStore2.Combine("DATA", "coins", "levels", "whatever", "etc")

And then just use the stores as normal

DataStore2("coins", player)
DataStore2("levels", player)
DataStore2("whatever", player)

Lets suppose that for some reason, there are 2 scripts:

One script contains:
DataStore2(“coins”, player)
DataStore2(“levels”, player)

Another script contains:
DataStore2(“whatever”, player)

In that case, how DataStore2.Combine should be used? It have to be used in both scripts right after requiring DataStore2?

2 Likes

The one script has:

DataStore2.Combine("DATA", "coins", "levels")

The other has:

DataStore2.Combine("DATA", "whatever")

3 Likes

Thanks I will trust the module and use it in my new game BloxyCity - Updates

Greetings kevini44

1 Like

Is Crazyman32s DataStore editor compatible with DataStore2?

1 Like

Wow! Thanks for the information, never knew about this until you posted this. :slight_smile:

1 Like

Pretty dumb question, but how would you take something from an IntValue with DataStore2? I never used this before, but saw the tutorial listed and have some understanding of it now, like how I used to do it: player.fjweoifgjgri.Value = player.fjweoifgjgri.Value - 50

1 Like

Can you access the DataStore of an offline player?

1 Like

No, that’s not how datastores work. I don’t even think you can make an offline datastore since if I’m not mistaken roblox removed a lot of the os file manipulation functions.

1 Like

You can access normal datastores of offline players with their key (probably their UserId for example). But DS2 requires the player instance, which makes that not possible

1 Like

Oh sorry I misunderstood your question, I thought you meant the roblox studio offline mode where you dont need wifi

1 Like

oh no, not that lol. Although it is possible, you can simulate local datastores for offline studio there is a thread for it I think :slight_smile:

1 Like

Yes, you just need backtrack the system to determine how it wrote the Scope and the Key to access the datastores you want to see.

This is probably a good thing to know how to do with the new European Data Privacy laws.

2 Likes

If this is your intent:

3 Likes

Hello, I have a question about my code, I’m just trying to verify that this code is correct since I don’t have a way to test if it works. Should my :SetBackup() and IsBackup() work correctly here?

DataStore2.Combine("MasterDataKey","pigment","petTokens","equippedPets","currentGun","currentBackpack","petInv","gunInv","backInv","music","trajectory","othersPaint","currentQuest","doneQuest","newPaint","amountPaint")

local pigmentSave = DataStore2("pigment", player)
local petTokensSave = DataStore2("petTokens", player)
local equippedPetsSave = DataStore2("equippedPets",player)
local currentGunSave = DataStore2("currentGun", player)
local currentBackSave = DataStore2("currentBackpack",player)
local petInvSave = DataStore2("petInv",player)
local gunInvSave = DataStore2("gunInv",player)
local backInvSave = DataStore2("backInv",player)
local musicSave = DataStore2("music",player)
local trajectorySave = DataStore2("trajectory",player)
local othersPaintSave = DataStore2("othersPaint",player)
local currentQuestSave = DataStore2("currentQuest",player)
local doneQuestSave = DataStore2("doneQuest",player)
local newPaintSave = DataStore2("newPaint",player)
local amountPaintSave = DataStore2("amountPaint",player)

pigmentSave:SetBackup(3)

if pigmentSave:IsBackup() then
	--alert player about backup
	player:Kick("Error loading game, please rejoin.")
end
2 Likes

That looks right to me, yeah.

1 Like

hey, since you wrote that function to clear an offline player’s datastore, can you please make one to retrieve an offline players one? I want to see data of offline players for a database lookup, thank you really appreciate it, this is the best module on this forum by far

1 Like

It shouldn’t be hard to slightly tune the script I made to do it. That being said, it’s possible it could be added in the future: A way to get data of an offline user · Issue #44 · Kampfkarren/Roblox · GitHub.

1 Like