PlayerService.PlayerRemoving:Connect(function(Player) DataStore:SetAsync(Player.UserId,game.ServerStorage[Player.UserId].Data) -- Saves players data folder game.ServerStorage[Player.UserId]:Destroy()-- Destroys folder when player leaves end)
And because Player Removing is always almost fired first the data store will throttle and I was wondering if this was normal
Cause most of the time Player Removing fires and that destroys the data folder also
which means bindtoclose cant save the data since it is destroyed
game:BindToClose(function() for i,v in pairs(game.Players:GetPlayers()) do DataStore:SetAsync(v.UserId,game.ServerStorage[v.UserId.Data]) end wait(30) end)
But since if Player Removing fires which it fires almost 99% of the time
It destroys the folder with the data in server storage
also almost everytime since Player Removing is fired before bindtoclose and since they both save in the 6 second cooldown they throttle
SO IN CONCLUSION I WAS WONDERING IF THIS WAS NORMAL
DataStore
throttling is caused when too many attempts to manage data is asked of the Service. It is actually preferred you keep BindToClose
however, because it is really useful when the server abruptly shuts down and creates a threshold where data can be lost. This is because, if you didn't know already, the metamethod allows the code within the scope to fire on the disconnection of the server, before it actually shut's down.
Either way, whether the player has lost connection or left, it still fires to BindToClose
. So if you desire to save, use BindToClose
, not PlayerRemoving
.
I'm going to look further into this to provide a better resolution, but for now, just try this.