We’ve added a new optional parameter to the PlayerRemoving event called exitReason, which tells you why a player left your experience.
This gives you more visibility into why a session ended, such as whether a player left voluntarily, was kicked by the experience, or was removed by the platform.
Details
This new parameter uses the PlayerExitReason enum. This parameter is only exposed on the server. On the client it will always return PlayerExitReason.Unknown. Initially, the enum includes three values:
Value
Description
Unknown
The reason for leaving isn’t known. (Always returned on the client.)
PlatformKick
The player was removed by the platform.
CreatorKick
The player was removed by the creator using Kick() or a similar API.
Here’s a simple example of how you can use it in your experience:
Players.PlayerRemoving:Connect(function(player, exitReason)
print(`{player.Name} left due to {exitReason.Name}`)
end)
Great update! Will there be a PlayerExitReason.Disconnected added in the future? It would be really helpful for games where players lose connection and end up losing their win streak, for example. I understand some might disconnect intentionally to exploit that, but in most cases, it would be a positive change.
This is something I wanted a decade ago for a PVP game I never ended up developing that far. Being able to understand intent for leaving (ex: leave before losing stats vs just lost connection at a bad time) would have been really useful.
The docs don’t seem to cover this, what enum would be passed for a player manually disconnect (leaving or closing client), and what would be passed for a connection timeout? The first one is not clear to me (Unknown?), and the second one I being Unknown or PlatformKick. We can differentiate these cases, right?
This is an excellent change for detecting player leaves. I run a system that tracks in-game activity and this’ll help in case someone gets disconnected by Roblox.
Will we be able to provide our own values for exitReason so we can let our scripts know why someone is being kicked? That’d make this system infinitely better for various reasons.
PlatformKick sounds pretty vague and seems like it’s a just ROBLOX-system kicked thing, could we have more documented examples on what constitutes as a PlatformKick?
Unknown right now serves as a catch-all, which isn’t really useful to know whether a client has disconnected voluntarily, due to a game crash, or anything along that line. what are the plans to make this more verbose in the future? or some sort of error code returned?
This is a great step forward in terms of visibility for developers and for Roblox. I hope the team working on Recommendation signals makes a good use of it.
Please note that PlayerRemoving fires when removing from a place, not from an experience.
Other common reasons could be included, such as:
Successfully teleported out to another place within the same game
We need a enum of them leaving and joining a different game.
Sometimes I am in a game, and someone invites me to a different game, I accept the invite and my client leaves the current game and goes to the invited game
Interesting. I imagine the PlatformKick as a thermometer for knowing whether players are being banned for exploiting or bad behavior
I wish it was a Teleport Enum as well or possibly a Crash Enum
Is CreatorKick also from migrating servers? This would help us with our combat logging system where players lose their items if they leave while in combat. If we can determine it comes from us migrating our servers we can prevent angry players. We have been using a weird workaround for this but it’s never been 100% reliable.