How to tell the difference between a player leaving and the game shutting down, for combat logging?

If I have combat logging in my game, where players can lose items if they leave while in combat. How would I be able to tell the difference between a player logging off and a game server shutting down?

I believe you can use BindToClose for this to detect if a server is being shutdown instead of them leaving and game.Players.PlayerRemoving:Connect(function(player)) for a player leaving

https://developer.roblox.com/en-us/api-reference/function/DataModel/BindToClose

game.Players.PlayerRemoving:Connect(function()
	print("a player left")
end

game:BindToClose(function()
	print("the server was shut down")
end)
1 Like