Updating Description Exceeds Limits and Kinda Dies

Boring Stuff: When I try to run this script, it keeps creating clones and crashing with the error: Maximum event re-entrancy depth exceeded for Player.CharacterAdded
This system is intended to force a player’s character to a specific appearance for the experience. However it’s been having a few… well… issues.
In ReplicatedStorage there will be 8 HumanoidDescriptions (in models) with unique identites, I’ve already gotten the picking out system but now I need to actually apply the appearance.

TLDR: I don’t know why but it’s looping the script and creating clones.

local RepStorage = game:GetService("ReplicatedStorage")
local Characters = RepStorage.StarterCharacters
local UsedCharacters = RepStorage.UsedStarterCharacters
local PlayerService = game:GetService("Players")

PlayerService.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local Character = math.random(1,#Characters:GetChildren())
		local SelectedCharacter = Characters:GetChildren()[Character]
		-- everything before this works properly
player:LoadCharacterWithHumanoidDescription(SelectedCharacter.HumanoidDescription) -- the problem child
		SelectedCharacter.Parent = UsedCharacters -- this should be fine
	end)
end)

I am getting a suspicion that when I do LoadCharacterWithHumanoidDescription it triggers the CharacterAdded event again too…

Yes, because you are technically loading the character in a CharacterAdded event causing it to fire again. You can try to get the HumanoidDescription from the Selected character and then load it with

Humanoid:ApplyDescription(SelectedCharacterHumanoidDescription)
1 Like

You know, I completely forgot that was even a thing I could do. Thanks for the help!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.