I tried to use the OnClose event, but it doesn't seem to work in game
game.OnClose = function() print("Closing") wait(3) print("Shutting down") end
game.OnClose
is a callback, it is intended to help game developers have the ability to save game data before a server is to shut down. The maximum wait time before a the game is forced to shutdown is 30 seconds. To trigger the callback, all players would have to leave the game or you have to send a shutdown signal to the game via the website. This just lets game owners have a few more seconds to save information to DataStores and send final requests to HttpServices and other necessary actions for the game.