Bind to close does not work when the player is kicked, If the player willingly leaves then it does count but if the player is kicked/disconnected then bind to close does not work, is this intentional or a bug?
If the player gets kicked, I believe that the server still stays running temporarily (which the Studio process likely doesn’t recognize as it automatically shuts down when the client disconnects).
Bind to close binds it to when the server itself shuts down. I believe then that when you are kicked only the player is removed, then the server shuts down, so the kicking to leaving action isn’t directly linked to each other (as opposed to leaving as the last player).
If anyone knows how it actually works, feel free to correct me on this.
Btw there is a bug rn (unsure if patched) if you have a singleplayer game and user leaves its better to have connection that kicks anybody who tries to join.
There is a vulnerability if you are in a queue of server that is about to shut you can revive it.
In Studio, the server is still running if you kick the test player. There’s no reason to invoke BindToClose if the server side is active.
There’s no logic to close the server when its empty in Studio, because you might want to test PlayerRemoving or other hooks based on player logic this way. If you close the server, PlayerRemoving, and other events, get terminated as soon as they yield (so that you cant just keep the server alive forever).