What does "Maximum event re-entrancy depth exceeded for Player.CharacterAdded" Mean?

I know there are already multiple topics about this error but i didn’t see anything about “Player.CharacterAdded”

  1. What do you want to achieve? Me and my friend @Exotic_Stuffing are making a script that loads a certain person a custom StarterCharacter

  2. What is the issue? It’s giving me the “Maximum event re-entrancy depth exceeded” error
    image

  3. What solutions have you tried so far? Currently, I did not find any solutions.

When i respawn, the camera breaks and i think that error is causing the camera to break

game.Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		if plr.UserId == 547000629 then
			local mm = plr.Character
			local as = mm.Animate:Clone()
			local devskin = game.ReplicatedStorage.DevSkins.garello:Clone()
			devskin.Parent = workspace
			devskin:MakeJoints()
			devskin:MoveTo(char.PrimaryPart.Position)
			plr.Character = devskin
			mm.Archivable = true
			mm:Destroy()
			as.Parent = devskin

			devskin:WaitForChild("Humanoid").Died:Connect(function()
				game.ReplicatedStorage.CameraThing:FireClient(char:WaitForChild("Humanoid"))
			end)

			for _, Script in pairs(game.StarterPlayer.StarterCharacterScripts:GetChildren()) do
				local ScriptClone = Script:Clone()
				ScriptClone.Parent = devskin
			end
		end
	end)
end)

2 Likes

An Easier way to make them start off with a custom Character would to be doing this: as shown in here

It means that the event is happening in a infinite loop.

I’m pretty sure he’s trying to give a custom character to a specific player.

So basically the Infinite loop is breaking the camera?

How could i break that loop???

how break loop???

Somewhere in this vicinity, add an if statement to check if they are already a custom character. What is happening is that when you change their character, it fires CharacterAdded again, and so their character changes, which fires CharacterAdded again. It loops until you get that error.
Also, this here

	plr.CharacterAdded:Connect(function(char)
		if plr.UserId == 547000629 then

If you swap those two lines, you’ll have (infinitesimally) better performance because you’re not going to run CharacterAdded for every single player, just for you.

2 Likes

still glitches and doesnt fix camera bug

What does your code look like after the change?