Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I put a table inside an existing table with DataStoreService?

Asked by 5 years ago

I already have something to make a table, but it overwrites existing data. How do I make it add data instead of overwrite data? I already have

local savetable = {a.Name, b, c, d}
    ds0:SetAsync("public", savetable)

to save it. But that overwrites...

0
Have you experimented with UpdateAsnyc? Pojoto 329 — 5y
0
Everyone I've asked has told me to use UpdateAsync, but I can't find anything on how to use it other than https://www.robloxdev.com/api-reference/function/GlobalDataStore/UpdateAsync which is a little confusing. keegaroo65 11 — 5y
0
Are you talking about adding data to the table as it updates? Or updating data? Anyways, I would use UpdateAsync(). B_rnz 171 — 5y
0
Adding data. Like a table already exists, but it ads a second table, without removing the first table. keegaroo65 11 — 5y
View all comments (4 more)
0
But seriously. *How do I use UpdateAsync??* keegaroo65 11 — 5y
0
The same way greatneil80 2647 — 5y
0
ds0:UpdateAsync(key, savetable) greatneil80 2647 — 5y
0
"Unable to cast Value to function" keegaroo65 11 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Got it. I just did

ds0:UpdateAsync("public", function(oldValue)
    local savetable = {oldValue, a.Name, b, c, d}
    local newValue = oldValue or 0 --oldValue might be nil
    newValue = savetable
    return newValue
end)
Ad

Answer this question