PcoWSkbVqDnWTu_dm2ix
Collapse Sidebar

PlayerDisconnecting

The PlayerDisconnecting Players event fires when a player is disconnecting from the game. It indicates the Player instance disconnecting.

This event is not intended for wide use and will not work in Scripts or LocalScripts. Instead, you can use the Player/PlayersAdded and Players/PlayerRemoving events.

Similarly, if you want to track when a player’s character is added or removed from the game, such as when a player respawns or dies, you can use the Player/CharacterAdded and Player/CharacterRemoving functions.

Parameters

Name Type Default Description

The Player disconnecting.


Code Samples


Player Connecting Disconnecting and Rejoining

This example demonstrates that the Players/PlayerConnecting, Players/PlayerDisconnecting, and Players/PlayerRejoining events fire when a player connects to, disconnects from, and rejoins the game. Each of the events fires a message with the player name and the action. For example, when a player connects to the game, the PlayerConnecting event prints:

PlayerName connecting!

This example will function as expected when executed in the command bar.