Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Saving a folder of values with DataStore2?

I AM USING THE MODULE DATASTORE2

I have been trying for the past 2 days to properly save a players inventory using datastore2, the inventory contains over 100 values of each slot of the players inventory, each value corresponding to an item. I need to loop through each value and save them with filling up the request queue, any suggestions? I would provide code but I only have my code for saving and loading player position because I deleted all my failed attempts to save inventory.

2 comments

0

Don't have 100 inventory values lmao. Especially with datastore2 which makes multiple copies. Save your inventory procedurally, you shouldn't use ds2 for an inventory anyway but if you have to, datastore2.Combine() can be called later on to use new values. Add inventory slot values as the player uses them, not all at once.

0

what should i use to save invetory instead of ds2?

1 answer

You need to loop through the folder and put all of the values in an array/dictionary and only save that dictionary to the datastore and recreate it into values on player join,

7 comments

0

I have put them all through a loop and converted the folder into a dictionary but I don't know how to make sure the values in the dictionary are the same as the values in the inventory folder when the player leaves, and I dont know how to save a dictionary.

0

On player removing and bindtoclose you create the dictionary and save it

0

ok I will try

0

ok I will try

0

for some reason it only saves once and keeps that save even when I add more items to my invetory

0

everytime i change the datastore key it will save but it keeps that save forever and doesnt update

0

Did you make a BindToClose() function as well? PlayerRemoving almost never fires when the last player leaves the game, the server shuts down before it has time to complete, so you need to use PlayerRemoving AND BindToClose to save the players data incase of unexpected shutdowns and when the last player leaves.

This discussion is preserved as it was. New answers, comments, and votes are closed.