game:BindToClose(function()
for i, plr in pairs(game.Players:GetPlayers()) do
plr:Kick() -- Apparently so that it fires the PlayerRemoving function?
end
end
and
game:BindToClose(function()
for i, plr in pairs(game.Players:GetPlayers()) do
saveData() --Saving the players data on BindToClose; I have problems with this one saying there's too many requests.
end
end
I’m using this for a module, which one should I use?
No, it’s for basic use, aka saving the players data when the server goes down;
And from what I’ve heard, but 'im not sure, kicking the player would fire the PlayerRemoving, and there fore not calling this twice when on testing on studio;
If your game is so unstable that you have specialized scripts ready for immediate action when your server crashes then i don’t think you should be asking for a good data saving but rather why it’s so unstable.
… That’s pointless because when the server is shut down and then the player gets kicked not because of the Kick() function, the PlayerRemoving event should be fired as well.
Listen, don’t worry about this function. When a player no matter what leaves the game or is kicked/disconnected then player.Removed will fire everytime no exceptions.
If a server crashes, you might not be disconnected instantly. You might disconnect later when the server IS GONE. There fore, not saving your data. Kicking would disconnect immediately and fire a player removing immediately, but saving the data could also work the same way, but could fire twice.
If that happends, BINDTOCLOSE can help you with that. But, like the person above said, it’s better to use RunService:IsStudio() because bind to close fires even when theres only one player and he leaves.