Way to detect a players stats as they leave

Hello!

is it possible to see the players stats as they leave?
For example, if the player has a value true then run an event on the server?
Thanks!

You can run a .PlayerRemoving event to see player stats as they leave

game:GetService("Players").PlayerRemoving:Connect(function(plr)
--if player value == stuff then
--end
end)
3 Likes

Adding on to this, you should run a game:BindToClose() which fires when the servers about to close, and this function runs before the server closes. This will ensure that everyone’s stats are saved before the server closes. The servers do close after 30 seconds regardless if the function is done or not which it shouldn’t take 30 seconds to save, but always a good thing to know.

1 Like