PlayerRemoving executes before CharacterRemoving

I just found that now PlayerRemoving can execute before CharacterRemoving.
Previously such behaviour never occurred in testing, so I presume it is a recent addition.

The work around is to explicitly synchronise these two event callbacks. However, it simply is not logical to fire PlayerRemoving before (or together with) CharacterRemoving.

RemovingInOrder

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterRemoving:Connect(function(char)
		local t = 1
		while t>0 do
			print(tick(), "CharacterRemoving")
			t = t - wait()
		end
		print(tick(), "CharacterRemoving DONE")
	end)
end)

game.Players.PlayerRemoving:Connect(function(player)
	local t = 1
	while t>0 do
		print(tick(), "PlayerRemoving")
		t = t - wait()
	end
	print(tick(), "PlayerRemoving DONE")
end)

Hmm, even if it is a recent addition, it might be the right way to do it. I’m pretty sure a PlayerRemoving event is fired the moment the player chooses to exit the game. Internally this would call on something like CharacterRemoving; i.e., it is a logical sequence based on the action of the player.

If the Character is removed before the player decides to leave, does that really mean they are leaving? To me, this sounds like a fix instead of a bug.

2 Likes