DataStore Questions

Hi, I am setting a few datastore things but I have 2 questions.

  1. If I set multiple asyncs, will they replace each other, or if I do SetAysnc() twice, will it save 2 different asyncs in the datastore.

  2. How do I access and save all of these values into a variable.

local DataStoreService = game:GetService("DataStoreService")
local fileStore = DataStoreService:GetDataStore("files")
fileStore:SetAsync(game.Players.LocalPlayer.UserId, script.Parent.Parent.Parent.FileName.Value, script.Parent.Parent.Parent.TextBox.Text)

You can only save one value when using SetAsync or UpdateAsync.

I’d recommend saving a table to a single DataStore.

Example:

someDataStore:SetAsync(player.UserId, {x = 45, y = 80})

Further clarifications, each time you call SetAsync, it will overwrite existing data with the given key, which is why utilization of UpdateAsync is probably ideal.

  1. If I do UpdateAsync will it save as different asyncs, but not override.

  2. Can I do fileStore:SetAsync(game.Players.LocalPlayer.UserId, {a = script.Parent.Parent.Parent.FileName.Value, b= script.Parent.Parent.Parent.TextBox.Text})

  1. You can’t save two values in a data store in the same key. Because how would you distinguish between the two. Save a table

  2. Yes

So how do I get the asyncs and save them to local variables like in the table above.

You use get async to get the data saved to a given key. Also async isn’t a noun :stuck_out_tongue:

So how would I save the a in the table to local a, and the b in the table to local b