Datastore Wont save in universes

Hi,
I have a script that saves inventory in the data store when the player opens a special chest he gets an item in inventory.
But when a player is teleported to the menu, and joins any game mode, he doesn’t have the item he got from the special chest.

2 Likes

Are you sure it’s solely because of the universes and not because of the datastore itself?

Does your “Successfuly saved data” message show correctly upon leaving?

2 Likes

Yes when player leaves, and no when player gets teleported.

1 Like

Is the data being loaded into the other universes?

1 Like

Yes, this script is everywhere expect lobby where you choose gamemode

But is it loading the data properly, as in, is it actually printing a load message

No, just my items dissapear after teleporting

1 Like

Use UpdateAsync for both reading and writing to ensure you get the latest saved data.

2 Likes

Does using GetGlobalDataStore make any difference to your code? That could be the issue.

Explanation

From my understanding of your post, you want to use datastores across multiple places within one game- afaik regular DataStores do not work across places, but GlobalDataStores do.
This may be incorrect, I should probably test this theory at some point.

Do you mean I should change
invData:SetAsync(plr.UserId…"-Inventory", save_inv)
to
invData:UpdateAsync(plr.UserId…"-Inventory", save_inv)
?

Ok i tried update async and getglobaldata store and this happened:
image

Check out how to use the function here: GlobalDataStore | Documentation - Roblox Creator Hub

1 Like