So I’m making a game and I use datastore2 to handle data saving.
I must be careful with my game as players can lose hard work and progress when they die (it is going to be a permadeath styled game) The game will also have occassional events where certain areas in the map may change in appearance. Or I may decide to add more to the map.
When you leave the game it saves the location u logged off at and puts u back when u log in. The issue with this is that lets say someone joins and enters a part of the map. That player walks ontop of a mountain and then logs off. Now lets say I add a house ontop of that mountain. When they log in they will not only be trapped under the house or in a wall. Other players will be flooding around the place as its new content they wish to explore. The poor man trapped in the wall will most likely be brutally murdered and lose progress.
To prevent this I wish to edit everyones spawn location data whenever I add something like this. (or alternatively, if possible, be able to check if their spawn data is near the new location and reset it if it is) I also don’t mind wiping spawn data completely from everyone if I have to as its not a big deal. But I would prefer to be able to edit it.
How can I edit / wipe a single key with datastore from everyone? All help is greatly appreciated!
let me specify on what im trying to achieve.
I want to wipe a key for ALL players. Not just one.
requires a userId of a player. I cannot manually get everyones userId and wipe their data that way.
My example wasnt the best so let me use a new one.
Lets say I have a game with currency and a massive dupe exploit comes out and people are getting millions of coins.
How can I wipe the coins of every player. Or edit the data of every player so they only get 100 coins. (Or if possible be able to determine whether someone has over 6000 coins and if they do set their coins to 1000)
I have an idea of an alternative way but I don’t know how I could execute it.
Is there anyway I can store the IDs of every player who joins into a table? Then save that table as data? Would that cause any problems?
You can use an OrderedDataStore, save the value to os.time() and set the key name to the user id (and then retrieve using :GetOrderedDataStore() and iterating through all players), but it seems a bit of an odd/unintended use case if you want to constantly be able to wipe a specific key in everyone’s data. You have to iterate through 1000s of players saved data which doesn’t scale well with Roblox’s data store limits. You’d be better off finding some alternate method to do whatever it is you’re trying to do as I think @aquawrsp is saying (for which it might be the case it’s easier to connect to DataStoreService yourself rather than using DS2).
Yes, see Data Stores | Roblox Creator Documentation (Error Codes and Limits section).
Roblox won’t queue queue requests past 30 so you have to be careful not to exceed the limit or you’ll end up silently dropping requests.