Question on data saving (SubTables)

I want to save some information stored in different folders within the player. Would it be possible to get a subtable, as shown below, from the data retrieved by the GetAsync() function?

If I do this…

local data = {}
data.subTable = {
          cash = 100,
     }
local key = "MyKey"
local success, errorMessage = pcall(function()
     dataStore:SetAsync(key, data)
end 
if not success then 
    warn(errorMessage)
end

Could I do this…

local data
local key = "MyKey"
local success, errorMessage = pcall(function()
     data = dataStore:GetAsync(key)
end

if success then
     --would this access the subtable and print 100?
     print(data.subTable.cash)
else
     warn(errorMessage)
end
1 Like

Looking at this example or table (similar to what I have written about) it seems possible

Yeah provided you set it before.

data gets set to the datastore table at "MyKey".

2 Likes