Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

when BindToClose is fired DataStore throttles is this normal?

Asked by 4 years ago
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

0
Try my new suggestion Ziffixture 6913 — 4y
0
only use PlayerRemoving no need to bind to close if you dont have to (please like trying to get a new rank) mattchew1010 396 — 4y
0
BindToClose is actually a better choice Ziffixture 6913 — 4y
0
Do what I suggested when you asked this two days ago. Have the BindToClose handler disable your PlayerRemoving code and do all the saving itself. PlayerRemoving will not fire before BindToClose except if a player just happens to leave right that moment on their own. EmilyBendsSpace 1025 — 4y
0
I mean, do you really need to destroy the player data? If the only issue is the removal of data before bind to close fires, then you could just do the simple task of not removing the information to begin with SerpentineKing 3885 — 4y

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
4 years ago

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.

Ad

Answer this question