You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I’m trying to make it where if you’re in the red team you get red’s avatar, as if your in the blue team you get blue’s avatar.
What is the issue? The characters do not get replaced with the current character. At the first attempt but after the character resets it prints “Maximum event re-entrancy depth exceeded for Player.CharacterAdded”
What solutions have you tried so far? I looked at the forums and tried some solutions but it still wouldn’t spawn. I’ve tried looking at tutorials but there aren’t many. I’ve also tried to find a solution for Maximum event re-entrancy depth exceeded for Player.CharacterAdded but they weren’t of any use.
local ServerStorage = game:GetService("ServerStorage")
local characters = ServerStorage.CustomCharacter.Default
game.Players.PlayerAdded:Connect(function(player)
print("000")
player.CharacterAdded:Connect(function(character)
print("311")
if player.TeamColor == "Electric blue" then -- doesn't get past here
print(111)
local newChar = characters:Clone()
newChar.Name = player.Name
newChar.Parent = workspace
player.Character = newChar
elseif player.TeamColor == "Dusty Rose" then
print(211)
local newChar = characters:Clone()
newChar.Name = player.Name
newChar.Parent = workspace
player.Character = newChar
end
end)
end)
I’m not getting any errors at first which is why I have the prints to see where the code stops.
Yes, so basically the character loads it doesn’t change its character but once the character resets or dies the camera will break and it will cause that error.
This occurs when you are setting a new character to the player.Character, I had this issue before and I believe I can explain
whenever you set a new player.Character, it will replace the character but then fire the player.CharacterAdded listening function–if you see where this is going its simply looping, that is why you get that maximum entry exceeded thing, it fired so many times it reached the maximum and I believe stopped.
local RespawnTable={}
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
--This here is needed as character added fires multiple times when activating morph changes, needs to stay here to prevent mass cloning
if table.find(RespawnTable, player.Name) then
table.remove(RespawnTable, table.find(RespawnTable, player.Name))
return
end
table.insert(RespawnTable, player.Name)
--change player.Character and I utilized functions to set up new morph
end)
end)
this is how i fixed the issue I had anyway, let me know if this fixes your issue @VoidPan_Dev
Never mind I just change the script from local to server. My bad. Also when It says change player.Character and I utilized functions to get up new morph that means I put the
elseif player.TeamColor == "Dusty Rose" then
print(211)
local newChar = characters:Clone()
newChar.Name = player.Name
newChar.Parent = workspace
player.Character = newCharacter