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

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

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...

8 comments

0

Have you experimented with UpdateAsnyc?

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.

0

Are you talking about adding data to the table as it updates? Or updating data? Anyways, I would use UpdateAsync().

0

Adding data. Like a table already exists, but it ads a second table, without removing the first table.

0

But seriously. How do I use UpdateAsync??

0

The same way

0

ds0:UpdateAsync(key, savetable)

0

"Unable to cast Value to function"

1 answer

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)

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