game:BindToClose() throws the following error on clients, while the deprecated
game.OnClose callback works on the client. This is undocumented and I’m not sure if its intentional.
I just wanted to append this bit here to clarify why I am making this bug report and what the reason I feel that it is a bug is.
I am not referring to detecting server shutdowns in client code, this is already easily possible to do and would be unnecessary behaviour. What I am referring to is the ability to run additional code when the client’s game shuts down (e.g. when the player leaves) using
:BindToClose() and delay the shutdown just a little so that data can be sent back to the server when the client disconnects. This was, and still is entirely possible to do with
.OnClose, and, it follows the exact same 30 second rule as
BindToClose (it also appears that scripts use significantly less CPU when the client is shutting down and trying to lag the game does not do anything to it).
This bug report is referring to the difference between the two. If the intention is that
:BindToClose() doesn’t work on the client for some reason,
.OnClose bypasses this and allows for this behavior to begin with. If the intention is that
.OnClose would work on the client, which would, like I said, be useful for sending back data to the server, than there is no documented reason as far as I am aware for
:BindToClose() not offering this functionality.
A few examples of what sort of data I am referring to:
- Simply analytics data. This is what initially gave me the idea to make this report, someone mentioned they wanted to be able to send some performance info back to the server upon a disconnect which isn’t possible to reliably do without usage of
.OnClose(which is deprecated)
- Knowing when the client shuts down intentionally and acting on that. This would be useful in a game where you might want to give the player some time to reconnect to a match if they lost connection, whereas if they close the game, you could assume that they are done playing. Again, already entirely possible using
- Debug information. Let’s say you have a lot of players leave a server at once, and you want to know why. This would let you know that these players left intentionally and would allow you to more effectively collect server/client errors. This one is probably less of a good one since Roblox mentioned potentially overhauling performance stats and adding the ability to collect these sorts of things more reliably.