I’m trying to make a game with feature of trading cards, where players can collect cards over the course of gameplay. Essentially, every unique card within the game will have an identifiable key, which will populate in the players’ unique array, which when loaded into a card screen, would autopopulate the visual representation of the cards based on the keys in said players’ array.
Right now, I can’t figure out how to save a list of data
I’ve looked on forums and Google, but I can’t find a solution targeting my problem.
Would it happen to be as simple as storing the name of the card in the player’s array, and then accessing a dictionary linked to that string that stores the properties of the visual card?
I don’t have a problem with adding keys into a player’s array, just asking how to save them when a player leaves, similar to DataStore, although I read that datastore doesn’t work with lists/arrays
My bad I read it wrong, have you looked at JSONEncode? It returns a string version of an array that you can store in a datastore. You can get the array back using JSONDecode().
This worked perfect, for those that are wondering how I used this:
I made a string value and assigned it as a direct child of the parent (just like leaderstats but as a child to the player itself)
The string value will always have the JSON string, and when I use any GUIs to show the player’s cards, I will make a temporary array object that decodes the player’s JSON string for use within the GUI only (and use the temp object to display whatever info I need)
If there are modifications to the table, I modify the temporary object, encode it to JSON, then push it to the player’s JSON string variable.
Hope this helps anyone else who would like to add a similar feature.