Adding tables to datastores

How can I add so,ething to a table stored in a datastore?

Have a look at this tutorial about ProfileService.

1 Like

Datastore:SetAsync(YourKey,{TableDataInHere})

1 Like

But can I use UpdadateAync? :cake:

Yes you can use update async. :slight_smile: You would simply use GetAsync to get the exist table then use table.insert() to add more data to the table, then update the datastore.

1 Like

So GetAsync() to get the table, add the values, then UpdateAsync() to swap the old table out.

That is correct. Heres an example.

local DatastoreService = game:GetService("DatastoreService")
local Datastore = DatastoreService:GetDataStore("ExampleDatastore")
local ValueToChange = Datastore:GetAsync("YourKey")

table.insert(ValueToChange,"MagicalValue")

Datastore:UpdateAsync("YourKey", function(oldValue)
	return ValueToChange -- We inserted more data into this table value above
end)
3 Likes