I'm trying to change players' character models on respawn via player.CharacterAdded, however, when players' character model changes it simply retriggers the function again leading to a loop error to occur (Maximum event re-entrancy depth exceeded for Player.CharacterAdded). How can I make newly respawned players change into a new model with a function without triggering the function to start again?
Here is what I had:
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
local oldCharacter = player.Character
local newCharacter = game.WorkSpace.PreloadedAssets.NewCharacter:Clone()
newCharacter.HumanoidRootPart.Anchored = false
newCharacter:SetPrimaryPartCFrame(oldCharacter.PrimaryPart.CFrame)
player.Character = newCharacter
newCharacter.Parent = game.Workspace
end)
end)
