Hey, so im making something for a dear friend of mine and I need to check if someone is in the game he owns. Im writing a script that is going to refund all to currency people who have bought currency within his game as there was an accidently data wipe. I already have a massive JSON file of all the purchases made with the amount of currency to give.
To make sure data doesn’t get overwritten is there a way I can check if the player is in the game playing? If so im going to use messaging service to award the player the amount of in game currency they have purchased! The data I have is the USERID, is there any way to tell if the player in the game. If there is no way then I have a different idea in mind, but it will slow down the refunding process upwards of 2x-3x longer.
I did some researching and I had no luck finding anything.
What are your intentions? Are you running a massive data editing script in Roblox Studio or do you have another kind of approach to this situation?
The presence endpoint will give you this information. Check the game or place they’re in, then check it’s owner UserId via the MarketplaceService or the marketplace info endpoint if it’s non-null.
I said my intentions above, if the player is in the game and I refund the coins, once they leave the coins I refunded will be overwritten. So I want to make if they are in game its going to directly just add coins to the player and once it leaves it saves.
My other plan was to use the presence endpoint but that will take up to a few seconds for it to send the request, That’s why I asked if there is any other way.
Intentions as in how you intend to go about this. Obviously, retrieving the presence of a user in your game is a walk in the park, but your use case suggests otherwise. That’s what brought me to my script question, whether or not you intend to feed a list of UserIds into a mass-update script.
The only on-platform solution is MessagingService, but that in itself leaves ambiguity. You have to be able to determine who to fetch data from and so on. You aren’t going to find a more instantaneous solution than to pass around a query for servers to either add currency or update DataStores.
The presence endpoint method in itself still requires a hint of MessagingService by passing around a message to each server that if the specified player was found via presence in-game, then to increment their cash values and inform them of a restoration.
It’s topics like this why DataStore2 exists and why data restorations without an explicit setup from the developer are not typically granted automatically. All your precious user data was stored on a single key and an “accidental wipe” has now caused players both data and their paid items. Restoration may not even grant the lost player base from returning.
Couldn’t you use a table containing user name and payment owed saved in the Datastore and in your useradded script section check if there is any payment owed and do that process ending with removing the item form the table of payment owed.
As Datastore is across all servers it would not matter which server the player was on.
It would mean the player would not get the payment until next logon but maybe that’s acceptable.