Client detecting CharacterAdded and CharacterRemoved multiple times but not on the server

Hello, I’m trying to achieve a custom character loading sequence on the server so I can handle custom character events between multiple OOP classes.

I see the CharacterAdded and CharacterRemoved event on the server fire only once (as expected), but now my client CharacterAdded and the CharacterRemoved event for the LocalPlayer is firing several times (consistently 6 times to be exact).

Here is a code sample from the server for loading characters:

Players.PlayerAdded:Connect(function(player)
	object:PlayerAdded(player)
	player.CharacterAdded:Connect(function(character)
		local humanoid = character:FindFirstChild("Humanoid")
		if humanoid then
			humanoid.Died:Connect(function()
				object:CharacterRemoving(player)
				wait(respawnTime)
				player:LoadCharacter()
				object:CharacterAdded(player)
				player.Character.Parent = cons.Characters
			end)
		end
	end)

	player:LoadCharacter() -- load the character for the first time
	object:CharacterAdded(player)
	player.Character.Parent = cons.Characters
end)

Players.PlayerRemoving:Connect(function(player)		 
    object:PlayerRemoving(player)
end)

Here is some code that sits in a local script on the character:

print("NICE")

which prints 6 times the moment a character respawns.

Has anyone experienced similar behavior or can point out flaws in my code?

Does Object spawn the player’s character? If not, it’s possible the character was already created before the CharacterAdded event even started listening.
A solution to it would be local Character = player.Character or player.CharacterAdded:Wait()

1 Like

Sorry for the slow reply. The Object's don’t spawn the character. The objects only listen for CharacterAdded function calls. I also made sure to disable CharacterAutoLoads so the character only loads at the time of the code provided above.

Your provided solution for waiting for the character definitely helped on the client.

Today after playing around with the DescendentRemoving I noticed the character being removed exactly 6 times on the server as well as the client… So after further investigation I realized some of the code I didn’t provide on my post, accidentally created the character loading events 6 times.

for _, object in pairs (customObjects) do
    ... -- the code from orignal post here
end