I’m trying to find a way to save tables. I have gotten it to save, but any table within the table being saved does not get saved with it, and all of its data is just transferred to the main table being saved. How do I fix this?
Edit: For context, this is what the saved data looks like in the output:
There are no names, just the number of their order and the value.
Each value should have a name, and they should all be seperated into their own subfolders within the main one.
function Save(player)
local success, errormessage = pcall(function()
myDataStore:SetAsync(player.UserId.."-DATA", json)
end)
if success then
print("Data Successfully Saved.")
else
warn("There was an Error Saving Data",errormessage)
end
end
(json is the encoded table mentioned earlier in this post originally it was just the table, but the json doesnt seem to affect anything besides the data now being listed on one line instead of one line per value)
Circling back to the beginning of my post, how do I get the subtables to be saved, and not have their data be transferred into the main table? My game requires these sub-folders, as each player can pretty much have an infinite combination of table data including:
Integer Values
Models
String Values
If I just try to use one table, there is no way to know what is what within it, as Player1 might have X models, and Player2 might have Y. The only consistent way to do this is to have these sub-tables that I am trying to get to save with their main parent table. And the names of the values are not saved, just the value itself, so there is no way to know what value is which when it changes throughout gameplay. These values also are not in the same order as they are listed in the script.