After updating the data, the 2 print statements within the :UpdateAsync() function print the correct values, but the one outside of the function that gets the updated data still prints incorrect data.
(Lines 70, 71, 72, and 77 are relevant print statements.) I am also unsure why there is an instance there as this is the only function modifying the Data Store. All help appreciated!
-- set product info in datastore
MarketStore:UpdateAsync('Main', function(data)
if type(data) ~= 'table' or data == nil then
data = {}
end
if data[name] == nil then
print('data is nil, set to empty table')
data[name] = {}
end
table.insert(data[name], {
id = assetId,
price = productInfo.PriceInRobux,
userId = player.UserId
})
print('updated data:')
print(data)
print(data[name])
return data
end)
task.wait(2)
print(MarketStore:GetAsync('Main'))
