Data Store Question About Saving

I have created a menu, where I only need to load and save one value, when table that I load have 7 values in it.
What will happen if I will write a Script that saves only one value to a table with 7 values? Will that table have only one value after save or will it overwrite one value that I was saving?

2 Likes

Hi!

No, it will not override.

To override an object inside a datastore, use
datastorename:UpdateAsync()

Please correct me if I’m wrong or if I misunderstood! :wink:

1 Like

What do you mean here? You are talking about one value or the whole table?

1 Like

Hi!

I am still not sure what exactly your initial question was, but if I understood it correctly, you want to know if, when saving a table, and then saving it again with a different value changes the original one.
Before I write my answer, please elaborate.

So this is an example table that I save:

local ExampleTable = {
    Coins = 10,
    XP = 100,
    Hello = "hi!",
}

and my question is: what if I save this table:

local ExampleTable2 = {
    Coins = 20,
}

into the same place, where I stored Coins, XP Value and Hello String? Will it overwrite only the Coins Value and won’t touch the XP and Hello String or will it overwrite the whole table (so there will only be Coins in it)?

1 Like

Ah, I see now!

It won’t touch anything. If you store ExampleTable2 then you will have both ExampleTable and ExampleTable2. It won’t change Coins in ExampleTable

Do you know how to overwrite only one value in the table, so I don’t have to save the same 6 values?

1 Like

Hi!

The only solution I see for that is to get the entire table, change the value you want, and then Update the table in the datastore :slight_smile:

That’s what I got now. Anyways, thanks for your time!

1 Like