I have a database that keeps track of all the servers in my game. I need it to remove a server when it is being shut down so that its no longer in the database. Is there a way of detecting a server shutdown, and giving enough time to send an HTTP Post request?
✓ ANSWER ACCEPTED
How do I detect when a server is shutting down?
2 answers
✓ Accepted answer
You'll want to use
game.OnClose = function()
like TheHospitalDev said.
There is also a new feature called BindToClose which allows you to bind all your "OnClose" functions if you have multiple.
game:BindToClose(function()
print("Starting callback...")
wait(5)
print("Done callback...")
end)
You could try using the OnClose function.
game.OnClose = function() --When the last player leaves, connect.
--Do stuff here...
wait(60) --Waits a minute, should be long enough
end
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
OnClose should not be used because it is deprecated. Use game:BindToClose from now on