When using Test in studio I sometimes get an error in a server script where the player has left during a part of the script that is updating the player data in the data store.
The sequence seems to be:
A server script that has a time loop which every 5 minutes gives the player some money and increases their experience value.
The script uses a function from another server script that is managing the users datastore values.
The player exits the game via Leave at the same time as the data store script is processing the money increment.
The data store script fails at a point where it is using the internal table containing the users data.
The internal table values are removed by the function game.Players.PlayerRemoving in the datastore script.
Two Questions.
1 does this error stop this script from working and as its a server script stop it for all players?
2 What code solution should I use to manage this situation?
1 Like
We can’t help much if you don’t show us the code or error message. It sounds like some form of issue where you don’t check to see if the player is still in-game before adding cash/xp
1 Like
Can’t you test this if you make the 5 minutes into a few seconds or so to make it easier to happen, then you test the game with a local server and 2 players. Then (luckily Roblox allows you to leave the game on only 1 client) you make player 1 leave and see if the script is still running as intended for player 2?