Trouble with saving certain data

Hello!

Im making a gamepass ID code saver, and when I add two codes, they put it into the same value. Im not sure how to explain.



Thats should be all the code you need, if you need more, lmk. THANKS!

On your first line in your screenshot code, you’re only inserting one id into a blank table (data), then saving it to the DataStore. This means that the data will only save as the inserted id, and nothing else prior. To fix this, data would have to equal to the previous data table of ids, then it can have new ids inserted and saved.

1 Like

How could I do this? Im confused.

Can you show full code? It’s easier to assist you when we see your setup

Yes, may be a little messy.


Can you instead copy paste them here? It’s easier to read and re-format/write if needed to

Its cuz ur resetting the data every time. You need to get the current player’s data, then edit that

local data = datastore:GetAsync(plr.UserId)
--Now u edit this tbl by adding a new index and save that--

I forgot to add u gotta wrap that round a pcall

Its because you are saving new table instead of saving the previous one so it’s better to load the player’s data first to prevent throttling.

So than, after this, I would add the data into the table using set async?

Is there anyway to add the table on and on again?

Yes ! first, load the player’s data and store it in a table. Then, save the player’s data based on the table to avoid loading the data multiple times. Ensure that all changes are made to the table as well, to keep it same as you have right now.

This worked! But now, the data is just not saving to my datastore. any idea why?