Players should be disconnected on Player:Destroy() instead of spectator state

As a developer, I find it weird that players aren’t disconnected when their Player:Destroy() is called like on normal instance. Instead, they are left in a spectator-mode-like state where they can’t do anything except watch.

The current behavior causes issues because players affected this way won’t immediately know that they’ve been removed from the game. They’ll struggle for a bit clicking through menus until they do find they’ve been removed.

If this issue is addressed, it would improve my development experience because the behavior would be less weird for players and me.

Instead of the current behavior, I think players should be disconnected and shown an error message.

Behavior in Detail

When a Player object is destroyed, the server’s scripts will register that player as being disconnected, but the player will remain connected. The player won’t see an error message. Instead, their character and GUI will disappear and all their LocalScripts will stop working. The server’s scripts also can no longer interact with the player since their Player object is gone.

To reproduce, first, with another player, join a game you have scripting access to. Then, type this script into the developer console command bar.

   game.Players["Your Player Name"]:Destroy()

The reason we need another player is if you do this on a server by yourself, the server will automatically shut itself down, triggering an error message that is misleading for reproducing this behavior.

Side Notes

  • I think ModuleScripts running from null will continue to run, but I can’t create any GUIs to display what’s going on, because the PlayerGui is also gone.

  • Sorry about my slow actions in the video. Running another client on my computer made it slow.

  • I found this behavior having been kicked this way many times with annoying scripts in a script builder.

3 Likes

If you want to disconnect players use Player.Kick

I like how Player.Destroy works, I usually do this to annoying players, spammers, exploiters and such.

I don’t see any issues with how it currently works

12 Likes

If I Kick a player, they are shown a Disconnected message and I can only show a short string why. If I Destroy a player, I prevent them from making any visible changes to the game just like with Kick (I know FilteringEnabled but also no exceptions to FilteringEnabled and no character loading. But if I Destroy them I might be able to show them a Banned screen with an Appeal button of something, but that is not possible with Kick.