Hey guys! So I just had a question regarding what is the best way to create DataStore data and stuff like that. (player data.)
To clarify further, I mean like, data you want to give each player that joins in your game. For example, maybe a money value, some items you unlocked, or whatever it might be.
How I used to go about this for a very long time is like this: I would insert tons of instance values inside the player when they would join in the game, and I would edit those values throughout the game. When they would leave, I would use an iterator to iterate through all of those values within the player, then save it to a datastore using SetAsync. I already know that’s taking a big risk, so in more recent years of programming I’ve added some conditional statements to make sure the data has loaded before resetting the async. (if the player joins the game, then leaves before it sets any of the values to the saved data.)
Considering the limitations I have using this method, being unable to manipulate bigger data I need to save. Like, active quests, quest data, and all that kinds of deeper stuff. That’d be extremely hard to create using this older style of data saving I’ve used for awhile. So with that, a new method I came up with is this: I have a module that each player requires when they join in the game, and the module returns the player’s data table. It fires a remote to the server to check/return the player’s previously saved data, then returns that data table to the client. I realize this way of saving/accessing/updating data might be iffy, or hackable, but it sure is a lot easier to manipulate than the other way. So like, I would require the module to return the player’s data, then I would simply update the values in the table returned, then when ever I would need to save that data to DataStores, I would call the save_data() function I’ve created in the module, which handles exactly that.
I’m also required to have the GUI set so it never resets, as that would wreck everything if I haven’t saved the data beforehand.
I just wondered what you guys thought of these methods, specifically the newer method mentioned below. If you guys had any better ways to handle data, please share! I’d love to research/practice new ways of doing this. Also, if you could comment regarding limitations/security of the newer method I’m using that would be great as well.
Thanks guys!