So for my game, I started off with a really crappy and unoptimized save data system that had a lot of keys and now I’m fixing it and optimizing it but I’m running into a huge problem.
local OLD_DAT = {dataStore_OLD:GetAsync(id.."-coins"), dataStore_OLD:GetAsync(id.."-wins"), dataStore_OLD:GetAsync(id.."-yesEmote"), dataStore_OLD:GetAsync(id.."-noEmote"), dataStore_OLD:GetAsync(id.."-yayEmote"), dataStore_OLD:GetAsync("-cryEmote")}
How can I grab multiple keys at once without overloading the data store? Thanks!
Edit: I just realised my question was unclear with my goal, I’m making a new save data system and I want to transfer the old save data to the new save save data system but I’m running into rate limit issues.
When you want to load the data of a player, like checking if he has enough money for a purchase, you can check at that moment if he is from an older version of the datastore, and update it right away.
Example:
if datastore_OLD:GetAsync(id…"-wins") then --this datastore is outdated
–update to the newer format of the datastore.
else --datastore is already updated.
end
Problem with this is that if you have multiple versions of datastore, you have to update each format with different lines of code.
I use and recommend you use ProfileService. The creator provides in-depth tutorials on how to work the module, and the majority of the work is already completed for you. Simply used that layout I posted above and then access it accordingly.
I am assuming you’re updating your data store to only use one key instead of multiple, and simply need to fetch the old data to create data in the new system. To do this, simply check your new datastore for data, if there’s no data there, then look in the old datastore. This means that you’ll only have to interface with the old datastore once, the first time the player joins the game after the update, and then you can continue to use the new one. That being said, I wouldn’t worry about overloading, you are making AT MOST 5 requests per player, and you get 10 requests per player in the game. If your situation is worse than it appears in your code, then a player throttle may be necessary, simply pcall getting the data, and if it errors, kick the player (note this should probably be done anyways in order to avoid players losing data if ROBLOX stores are down)
Could you outline your specific problem? What do you mean when you refer to overloading and are there any relevant output messages that you’re receiving? If by overloading you’re referring to rate limits, then you can try and stay under budget by checking if you have enough to make your requests with GetRequestBudgetForRequestType.
This is a worst case scenario suggestion but if you have a lot of data stored like that then you’re not going to find an easy way to transfer that data over to a new style that’s more efficient and respective of limits. In short, I’m suggesting that you wipe data (i.e. by ignoring old DataStores in your game) and going forward start employing best practices when working with DataStores.
My apologies, I made the question unclear. So in my game I have like 4 emotes, yes, no, yay, and cry. And I have money and wins, I wanna rewrite my whole game because I made it almost a year ago with one of the crappiest systems any developer could make. So in this case I’m starting off by rewriting my save data and the old save data system had the following keys, id being the user id: id-coins, id-wins, id-yesemote, id-noemote and so on and I wanna transfer all those keys into one table to save it but I have to get all the values via :GetAsync(). But I’m going over the rate limit.
I recently got the idea of just transferring all the data manually meaning ill grab all the keys and manually put it into the new system (in which is a pain in the butt but a job willing to be done).
Yeah, you probably aren’t transferring those keys any time soon. There’s no way to query all keys of a DataStore so even if you were willing to put in the pain to transfer them by hand you don’t know where to start. Problem one is just getting the keys. Problem two is (if you want to) remove the keys which would double your request amount. Problem three is saving the converted data.
It does suck to have this as an option but if that were my case I’d just nuke old data completely in favour of updating the save structure. I’ve done this on a few games before, it simply wasn’t worth spending the time trying to hand convert it when I didn’t have the proper data structures in place.
Can’t offer you any real help beyond that, other than to space out your requests by minutes. Scale that across everyone who has save data in your game ever and that just doesn’t seem worthwhile.