I’m trying to loop over this object (folders) grab all the data from it, put it into a table, and then save the table (for datastorage purposes, you cant save folders). I had this working fine yesterday, but obviously, I changed something along the line somewhere and i’m not sure where.
These are the folders that i’m looping through.
This is the code that is doing the looping. Here is where things start to get messy.
Currently, i’m checking what the data is before its stored, which is wrong.
the name key in the second table needs to be BetaQuest, not a duplicate of TEST.
Not only is the data that is being stored inncorrect, but when the game loads the data, this happens.
No name key on either tables.
not sure which direction to look in first, couldnt really find too much on here to help with that.
Well several things go wrong here. The first is simple, the loop variable v contains a reference to your object, and not a string. References to objects cannot be saved in datastores, so those are lost. You could simply use
questdat.name = v.Name
The other thing going wrong is a bit more tricky… You have a table ‘questdat’ in which you save the data from that run. However, you then reuse that table and fill it with the next object.
But table.insert puts a reference to your questdat table in your savedat table (instead of a copy). That means that if you change questdat afterwards, the stuff in savedat will also change.
That’s why you essentially have multiple copies of the data of your last object in the loop in your datastores in the end. To solve it, just make a new table at the start of each loop, and save that, instead.
Hope this helps! If it’s not clear I can try to explain it better. Good luck!