Changing player's character script makes the player weird

I’m making a game inspired by Super Smash Bros but for some reason the script the change the player’s character to their desired character somehow makes the player start being weird, like the local script in the PlayerGUI which is responsible for the camera keeps duplicating and destroy itself for no reason. I am still bad at scripting or Roblox Studio stuff so I don’t understand why this happens and couldn’t find any sources that talks about the problem (Probably because it’s kind of specific)

The problem currently / What happens:

What is supposed to happen:


(Morph script disabled)

Morph script:

game.Players.PlayerAdded:Connect(function(plr)
	local picked = Instance.new("IntValue", plr)
	picked.Value = 1
	picked.Name = "picked"
	
	plr.CharacterAdded:Connect(function(char)
		wait(.01)
		if picked.Value == 1 then
			local oldchar =  plr.Character
			local morph = script.chars.combatdummy:Clone()

			morph.HumanoidRootPart.Anchored = false
			morph:SetPrimaryPartCFrame(plr.Character.PrimaryPart.CFrame)
			
			plr.Character = morph
			morph.Parent = workspace.Tracking
			oldchar:Destroy()
		end
	end)
end)

Camera Script:

local cam = workspace.CurrentCamera

local xoffset = 0
local yoffset = 2
local zoffset = 10

local tracking = workspace.Tracking

local camPart = Instance.new("Part")
camPart.Anchored = true
camPart.Name = "CamPart"
camPart.Parent = workspace
camPart.CanCollide = false
camPart.Transparency = 1

cam.FieldOfView = 80

function calculateAveragePosition()
	local total = Vector3.new()
	for _, char in pairs(tracking:GetChildren()) do    
		total += char.HumanoidRootPart.Position
	end
	return total / #tracking:GetChildren()
end

function calculateAverageMagnitude()
	local total = 0
	for _, char in pairs(tracking:GetChildren()) do    
		total += (char.HumanoidRootPart.Position - camPart.Position).Magnitude
	end

	return total / #tracking:GetChildren()
end

wait()
cam.CameraType = Enum.CameraType.Scriptable

game:GetService("RunService").RenderStepped:Connect(function()
	local averagePos = calculateAveragePosition()
	local averageMagnitude = calculateAverageMagnitude() + zoffset

	camPart.Position = averagePos
	cam.CFrame = camPart.CFrame * CFrame.new(Vector3.new(xoffset, yoffset, averageMagnitude))
end)

! any help is appreciated !