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.
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?
Yes when player leaves, and no when player gets teleported.
Is the data being loaded into the other universes?
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
Use UpdateAsync for both reading and writing to ensure you get the latest saved data.
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:
Check out how to use the function here: GlobalDataStore | Documentation - Roblox Creator Hub