Accessories not destroying

The accessories here are not destroying despite being parented to the character. It seems to work normally twice but breaks after three times.

if not (Player.Character:FindFirstChildWhichIsA("Accessory"):FindFirstChild("IsArmor")) then
				Button.BackgroundColor3 = Color3.fromRGB(170, 0,0)
				Button.UIStroke.Color = Color3.fromRGB(85, 0,0)
				Button.Text = "Unequip"
				SelectedItem:FindFirstChildWhichIsA("Accessory"):Clone().Parent = Player.Character
elseif Player.Character:FindFirstChildWhichIsA("Accessory"):FindFirstChild("IsArmor") then
				for i, v in ipairs(Character) do
					if v:IsA("Accessory") and v:FindFirstChildWhichIsA("BoolValue") then
						if v.Name == SelectedItem:FindFirstChildWhichIsA("Accessory").Name then
							Button.BackgroundColor3 = Color3.fromRGB(0, 170,0)
							Button.UIStroke.Color = Color3.fromRGB(0, 85,0)
							Button.Text = "Equip"
							v:Destroy()
						elseif v.Name ~= SelectedItem:FindFirstChildWhichIsA("Accessory").Name then
							v:Destroy()
							SelectedItem:FindFirstChildWhichIsA("Accessory"):Clone().Parent = Player.Character
							UnequippedEvent:FireClient(Player)
						end
					end
				end
			end

Could you try placing some print statements throughout your code to narrow down which part of your code doesn’t work?

1 Like

i added a print statement to the “elseif v.Name ~= SelectedItem:FindFirstChildWhichIsA(“Accessory”).Name” part and that part seems to only work once

elseif v.Name ~= SelectedItem:FindFirstChildWhichIsA("Accessory").Name then
	v:Destroy()
	print(v)
	SelectedItem:FindFirstChildWhichIsA("Accessory"):Clone().Parent = Player.Character
	UnequippedEvent:FireClient(Player)
end

Edit: I added another print statement to the “if not (Player.Character:FindFirstChildWhichIsA(“Accessory”):FindFirstChild(“IsArmor”)) then” part and it seems to be printing that after the part above stops working.

bumping this post since i haven’t found a solution