So I have been wondering if it is possible to add tables in DataStores. I already used SetAsync to set the first table in the DataStore, which is myTb. I removed SetAsync after that. Here is my code that I tried out:
local dataStore = game:GetService("DataStoreService")
local gds = dataStore:GetDataStore("gds")
local myTb = {{sName = "server", sNum = math.random(1, 9999999), sAvail = true, playersInQueue = {}}}
local key = "figure"
local f = gds:GetAsync(key)
local x = f[1]
for i, v in pairs(f) do
print(i, v)
end
for i, v in pairs(x) do
print(i, v)
end
local function updateAvailability(currentValue)
local serverTable = currentValue[1]
local serverName = serverTable["sName"]
local serverNumber = serverTable["sNum"]
local serverAvail = serverTable["sAvail"]
local plrsInQ = serverTable["playersInQueue"]
local updateServerAvailability = {{sName = serverName, sNum = serverNumber, sAvail = false, playersInQueue = plrsInQ}}
return table.insert(f, updateServerAvailability)
end
local success, newVal = pcall(function()
gds:UpdateAsync(key, updateAvailability)
end)
if success then
wait(1)
local log = gds:GetAsync(key)
print(#log)
end
At line 36, I am expecting the number of tables in the DataStore table will be two, however, the output says it is only one. Did I make any mistakes in my code?

2 comments
Yes, grind that rep, I'll upvote you along the way
Thank you soooo much!