How Do I Delete a Duplicated Accessory Weld

  1. After a player transforms and then turns back to normal, all of their accessories get an extra accessory weld, when I check the extra weld it says it is not active. Since the player got an extra weld because they transformed, the weld will attach itself to any other person who is transformed. I have tried deleting the extra weld in the script but when I do, everything is normal for a few seconds until the accessories get deleted. It works fine when I access the workspace myself and delete the welds myself though.

This code is for deleting the extra weld.

for i,v in pairs(character:GetChildren()) do 
				if v:IsA("Accessory") then	
					for j, x in pairs(v:GetChildren()) do
						if x:IsA("Part") then
							local weld = x:FindFirstChild("AccessoryWeld")
							
							for k, c in pairs(x:GetChildren()) do
								if c:IsA("Weld") then
									print("weld")
									
									if weld then
										weld.Enabled = false
										print("destroyed")
									end
								end
							end
						end
					end
				end
			end

(Do note that I have tried to check for the welds active property to see if it is false, but it does not work. But when I checked if the weld was true, it worked and deleted all the welds, so I tried adding a 0.1 second delay but my solution still did not work.)

This code is what I use to transform the player.

local heatblastModel = game.ServerStorage.Models.PrototypeOmnitrix.Aliens.Heatblast:Clone()
		local cooldownClone = game.ServerScriptService.Player.Abilties.PrototypeOmnitrix.Cooldowns.HeatblastOSCooldowns:Clone()
		cooldownClone.Enabled = true
		task.wait(0.5)
		
		local playerFolder = Instance.new("Folder")
		playerFolder.Name = character.Name
		playerFolder.Parent = game.ReplicatedStorage
		
		local oldCFrame = character.HumanoidRootPart.CFrame
		
		character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
		
		for i,v in pairs(character.Humanoid:GetPlayingAnimationTracks()) do
			v:Stop()
		end
		
		for i,v in pairs(character:GetChildren()) do -- for parts that arent humanoid/scripts in player
			if v.Name ~= "Humanoid" and not v:IsA("Script") then			
				v.Parent = playerFolder
			end
		end
		
		for i,v in pairs(character:GetChildren()) do -- sets reset of children of player to storage
		    v.Parent = playerFolder
		end
		
		for i,v in pairs(heatblastModel:GetChildren()) do -- gives heatblast model to player
			v.Parent = character 
		end
		
		character.PrimaryPart = character.HumanoidRootPart
		character.HumanoidRootPart.CFrame = oldCFrame
		
		game:GetService("RunService").Heartbeat:Connect(function()
			if effectPart.Parent ~= workspace.Effects then
				return
			end
			effectPart.CFrame = character.HumanoidRootPart.CFrame
		end)
		
		local playerFolderChildren = playerFolder:GetDescendants()
		
		for _, children in pairs(playerFolderChildren) do -- gives playerfoldr children to player
			if children.Name == "Humanoid" then
				children.Parent = character
			elseif children:IsA("Script") then
				children.Parent = character
			end
		end
		
		local newOmnitrix = character["Left Arm"]:WaitForChild("Prototype Omnitrix")
		newOmnitrix:Destroy()
		
		character["Left Arm"].DialTop:Destroy()
		character["Left Arm"].Motor6D:Destroy()
		
		character.Humanoid.isRolling:Destroy()
		character.Humanoid.rollingEnabled:Destroy()
		character.Humanoid.movesEnabled:Destroy()
		
		character.Humanoid:SetStateEnabled(Enum.HumanoidStateType.Dead, true)
		
		game:GetService("RunService").Heartbeat:Connect(function()			
			if playerFolder.Parent ~= game.ReplicatedStorage then
				return
			end
			
			if character.Humanoid.Health == 0 then
				playerFolder:Destroy()
				omniActivate:FireClient(Player, "3")
			end
		end)
		
		cooldownClone.Parent = character

Am I going about deleting the extra welds wrong?