I’m having trouble adding a new dict to a pre-existing save in a datastore… So this is what I’m doing:
local Data = {}
table.insert(Data, GetData) --2022 data
table.insert(Data, DefaultTable) --2023 data
pcall(function()
ActivityData:SetAsync(Player.UserId, Data) --setting it
end)
When doing this, the datastore changes to this:
When really that “1)” and “2)” shouldn’t be there… How would I remove that?
That isn’t an error but a warning, saying that next() can return multiple values which could break table.insert(). In this situation it won’t.
But table.insert() is for arrays, so that doesn’t make any sense. You have to do what HugeCoolboy2007 said.
local data = {}
data["2022"] = GetData
data["2023"] = DefaultTable
Or like this
local data = {}
data["2022"] = GetData["2022"]
data["2023"] = DefaultTable["2023"]
-- or
function mergeDicts(a, b)
for k,v in b do
a[k] = v
end
end
local data = {}
mergeDicts(data, GetData)
mergeDicts(data, DefaultTable)
I’m not quite sure what structures GetData and DefaultTable have