Is it possible to bind a function to game crash?

My game has like ~25% crash rate on devices like iPhone 6, iPad Air 2G, iPad Air. All of these have 1 GB of RAM which I think crashes are because of this but I want to get crash info. Is it possibile to bind a function to game crash?

Only thing remotely close would be the .PlayerRemoving event, which fires whenever a client leaves the server. Even if a client disconnects from the server (crashing, disconnecting from wifi, etc.) they will still trigger this event. It does not provide any information regarding how the player disconnected, rather than the client that disconnected.

game.Players.PlayerRemoving:Connect(function(player)
    print(player.Name .. " disconnected from the server!")
end)

Yes, game:BindToClose() function runs right before the game shutdowns. This option gives you 30 seconds to run all of the functions bound to it and then forces the final shutdown of the game.

1 Like

That’s for the server shutting down, what OP is wanting to know is how to bind a function to a player crashing/disconnecting from the server. Anything remotely close to that would be the .PlayerRemoving event of the Players service.

By devices, what OP really is referring to is the clients that are playing the game. When these devices crash, the entire server is not crashing. The clients are simply disconnecting.

You could try optimizing your game to use less memory, but 1GB of ram is a bit of a lost cause especially depending on your game and I would say don’t waste your time worrying about those users.

You could try emulating your game with low device memory and looking at the developer menu to see what it’s usage averages around

I assume the question was asking about a final game shutdown and not a shutdown per-client, because in this case PlayerRemoving is indeed the only method to obtain it. But it can easily be combined with game:BindToClose() to also obtain information regarding the last player leaving the server, resulting in a server shutdown.

Good idea actually, I can create my own preset as one of these and try.

Actually these devices have less RAM than 1 GB because other apps and the OS still uses some RAM.

Servers aren’t shutting down, it’s clients. Also I don’t think that client memory usage is replicated to server.