I think I potentially found the root of the problem
I wrote a long reply before explaining how my system works then scrapped it because I think I found the root of the problem
So to sum it up, I have a reference module in Replicated Storage with all the Items and their properties. When the client buys something, they send a Remote to the server with the ItemID, then a ShopHandler script calls :AddItem in the PlayerData Module. The PlayerData Module can see what type of item it is and manually puts it in the table accordingly.
So really right there I can manually make a path_array easily.
The way I’m saving players data is in one datastore using @loleris’ ProfileService, so all data is nested in Profile.Data
The root of the problem
Until now the game I’m working on is privated (it’s not ready) and I’ve already made so many changes to the Data Structure (correct terminology?)/hierarchy of nested tables.
What I’m scared of is what if I want to change the hierarchy after my game is released, and there are already profiles with the “legacy” Data Structure.
example
local Profile = { -- gets saved to DataStore via ProfileService
Data = { -- table with all the player data
foods = {
banana = "banana",
apple = "apple",
},
},
}
Which I then want to change to this
local Profile = {
Data = {
foods = {
fruits = {
apple = "apple",
banana = "banana",
},
vegetables = {
carrot = "carrot",
},
},
}
}
Any code that assumes something is in a certain path (basically all my code handling the PlayerData, will break because the path has changed.
If I then update my code, the code won’t be able to read any “legacy profiles” that were created before the change. I could then probably make a “Legacy to New” function where I specify which old tables go in which new location but it seems like a pain.
Basically I really just want to know how the pro’s do it, how do the big games like Jailbreak manage and replicate Player Data, while making it future-proof.