Data Rollback / Reverted

I seem to be experiencing a problem similar to this where a user would purchase a dev product to gain an item, then they would teleport to a universe but that item would be lost in the universe they teleported to as if they got rolled back / reverted. Not sure if it’s caused by them teleporting to a universe too quick after they bought an item or something else

You should save the players data before you teleport them, because the other universe won’t see the product they bought, and that server will override their data with what they saw.

But the other universe they teleport to is a reserverdserver created as a separate instance for them, so it’s a newly created instance. Sorry for using the wrong term, universe was probably incorrect to use in this case

Yes, but the same thing will most likely happen. The reserved server will not see the product the user bought because it wasn’t saved quick enough, so it will override the data when it saves in the new server.

I see, thank you for clarifying. Would you suggest I save the data when they prompt the teleport and yield the teleport until the data is successfully saved then the teleport can go through? Or should I add like a wait before the teleport.

Also the game has a saving function that fires on PlayerLeaving, so i’m not sure why that isn’t effective enough to fix this problem

Datastores can be challenging to deal with sometimes. Maybe you should use Datastore2 or ProfileService for your game. It would probably solve your issue. (it handles cross-place data saving)

I used a form of profile service in the database already, which is session locking. And I am not looking to convert my current database to Datastore2 or any other databases as there is already a lot of data saved, so I’d rather not risk the data wipe.

That makes sense. I suggest simply just saving the player data a few seconds before teleporting. This can be done with a teleport loading screen that will intentionally wait for 3 seconds, and would carry on to the new server like any teleport gui would, so you have time to save the data.

I see, what difference would that make from PlayerLeaving activating the datamodule save function I have?

It’s more reliable to save specifically before teleporting, because then you can control when the player leaves. Even better, SaveAsync will wait until it’s done saving, so you can use this yield just before you teleport the players to prevent any wasted waiting time. The PlayerRemoved event will most likely fire late because the player doesn’t immedieatly ‘Disconnect’ from the server when they leave, especially if they’re teleported. If saving before they teleport doesn’t work, I suggest just keeping your old saving system.