How can I add so,ething to a table stored in a datastore?
Datastore:SetAsync(YourKey,{TableDataInHere})
1 Like
But can I use UpdadateAync?
Yes you can use update async. 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