Need help on handling player's data

Let’s suppose I have a table like this

local stored_players_data ={}

And whenever a player enters the game their data is imported into a single table made with the player’s name, and after the player leaves, if the server manages to save, the stored player’s data will be deleted, and if not, the server will repeat the attempt to save the data limited times or until the player data saves, however there is a problem, if the player data saving happen to fail and the player enters the same server, the player data e will not be able to be loaded nor accessed because the data will be deleted a short time after the player leaves, either until reaching a limit of attempts or at success on saving. Any suggestions to fix this issue?

1 Like

Your question is very bulky and I’m missing the main query.

I suggest updating data in a 30 second interval and saving when player leaves or game closes.

Players.PlayerRemoving:Connect(function(Player) -- Will Save the Data of the player leaving
UpdateData(Player)
end)


game:BindToClose(function()
--//this function for saving data when game is shuting down

	local players = Players:GetPlayers()
	for _, Player in pairs(players) do
		UpdateData(Player)
	end
end)
1 Like

that’s not what i am trying to say. What im trying to say is, if the player leaves and the player’s data saving fails, the server will retry until success (or limited times). but if the player rejoins that server, the server will not be able to load the data because you cant create tables with the same name, and then after the server reaches success or the limit of retry, the player’s data will be deleted from the server, and no script will be able to access that data.

All i want is suggestions about fixing this issue

1 Like

Only, If it was stored on the server and left there. But normally you would remove this data when player leaves so

This is strange I think you believe the process of fetching data has more features than it actually has
something like that is created by the scripter. PlayerData would not just automatically be within the server until player leaves. unless a script does that.

1 Like

the player’s data is deleted after leaving, but 2 conditions:

Until success or until limited times

1 Like

And you seem to mention issues about saving failing are you running out of set request’s?

If that is the cause I recommend looking at how frequently you set data and fix the issue at the source

1 Like

This is veryyy vague
I’m not sure what you mean it deleted after it’s saved? I’m guessing
but this until limited times? can you explain a little more

1 Like

Its not saving failure. Everything in my code is correct my friend, server-locking, attempts after save fails and many other things. what I say is. the player’s data is kept on the server until the player leaves and the server manages to save, if the server fails to save, it will try again limited times until success. however if the player re-enters the server while the server is retrying the save, the player’s data will be deleted even with the player in-game and will cause alot of errors in other scripts

1 Like

If everything in your code is correct, then this issue shouldn’t happen. Why isn’t the server making the player wait until his/her data has been unlocked?

1 Like

It seems like you figured it out though.

"the player re-enters the server while the server is retrying the save, the player’s data will be deleted"

You just need to look over your code specifically in those parts cant* really help without code examples only speculation and speculation can only get me so far

1 Like