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

Can I use global data stores for this?

Not sure what you mean by this? Do you mean with non-player keys? If so, no.

1 Like

If I save data in place1 then teleport the player into a branch-place can I still get the same saved data from place1?

Yes, DataStore2 works fine and keeps data between places of the same game.

2 Likes

I am planning on using this instead of the default datastore in my game, i am saving with tables.
if and how would this be possible? would i do it the same as if i was doing a normal datastore

tables are the only way i can save as my data needs large amounts of info such as level, xp, skins etc.

if i can’t do this, how would i do it?

Please read the thread.

3 Likes

Ok, so… i roughly understand how it’s supposed to work, but what i’m wondering is what does this imply? How does this affect throttling?
How do i go about setting the data? Do i still have to do ~ 3 min. intervals between saving, and if so, does it mean both of them, or just one?
My intuition says that i shouldn’t care about the regular data store causing trouble, if the keys are different, i’m not overwriting then, but i should have the ordered data store at intervals, is this true?

1 Like

Would it still be a good idea to just require the model you have on ROBLOX? I’m only asking because I don’t see that in your post anymore and noticed it hasn’t been updated since August.

1 Like

No, I don’t recommend this anymore. That model is outdated and Roblox Studio isn’t letting me update it.

4 Likes

Is it not possible to get player data for players that are not in the server? My use case is teleporting players to their friends who are in reserved servers using a reserve code stored in the friends datastore. But you can only retrieve datastores with player instances.

Something like…

local FriendPresenceStore = DataStore2("Presence", FriendUserId)
local Presence = FriendPresenceStore:Get({})
local PlaceId = Presence.PlaceId
local ReserveCode = Presence.ReserveCode
FriendPresenceStore:UncacheWithoutSaving() -- For example.
3 Likes

I’ve answered this several times in the thread, but no. This is planned, but no work has been done: A way to get data of an offline user · Issue #44 · Kampfkarren/Roblox · GitHub

2 Likes

this may be a silly question but, does the data save across places within games (for example will your “XP” value be the same in the Hub as Level1)

1 Like

Yes, I’m using this in a multi-place game and it works fine. Just make sure to save the player’s data before teleporting them.

2 Likes

He has answered a question similar to this before.

1 Like

i cant open in rbxmx file in my roblox studio only rbxl

Simply drag and drop the file on your studio application and it will insert the rbxmx file.
https://gyazo.com/4f607bf77f113fc5e9232199a1776025

2 Likes

Thank you so much :slight_smile: #30characters

1 Like

When a store is set as a backup, when should we know to clear it?
Should I set up something that checks every now and then to see if the DataStore is still failing, and then clear the backup when it succeeds?

@Kampfkarren

I’m not sure, you should be able to get away with never clearing it, as I wouldn’t expect the player to stick around anyway.

Would this be an effective way to store item ownership in DataStore2?

local inventory = {"Sword", "Baton"}
local defaultItems = {Sword = true}
DataStore2.Combine("Items", unpack(inventory))

local function PlayerAdded(player)
    for _, item in pairs(inventory) do
        local store = DataStore2(item, player)
        local owned = store:Get(defaultItems[item] or false)
        -- do stuff
    end
end

EDIT: I’ve been reading up on the API docs, and it seems that serialization is a good way to do this. However, I’m using combined data stores to sore currency amounts and it seems that serialization doesn’t work well with combined data stores??