well this script is supposed to show all your armors everytime one is put into your armor inventory but instead of showing the right amount it doubles or triples it and I've tried everything but it keeps duplicating the same value when showing the buttons and idk how to reverse it here's the script:

local player = game.Players.LocalPlayer
local character = player.Character
local buttons = {}

function refreshhelm()
	for i,v in pairs(player.ArmorInventory:GetChildren()) do
		if v:WaitForChild("IsHelm").Value == true then
		local button = script.ImageButton:Clone()
		button.Name = v.Name
		button.LayoutOrder = i
		button.Parent = script.Parent.Choose
		button.Image = v.HelmImage.Value
			table.insert(buttons,button)
		button.MouseButton1Click:Connect(function()
			if script.Parent.Choose.Selected.Value == nil or script.Parent.Choose.Selected.Value ~= v then
					script.Parent.Info.ArmorName.Text = v.HelmName.Value
					if v.Rarity.Value == 1 then
						script.Parent.Info.ArmorName.TextColor3 = Color3.fromRGB(109, 109, 109)
					end
					if v.Rarity.Value == 2 then
						script.Parent.Info.ArmorName.TextColor3 = Color3.fromRGB(0, 170, 0)
					end
					if v.Rarity.Value == 3 then
						script.Parent.Info.ArmorName.TextColor3 = Color3.fromRGB(0, 85, 255)
					end
					if v.Rarity.Value == 4 then
						script.Parent.Info.ArmorName.TextColor3 = Color3.fromRGB(85, 0, 255)
					end
					if v.Rarity.Value == 5 then
						script.Parent.Info.ArmorName.TextColor3 = Color3.fromRGB(255, 128, 0)
					end
				script.Parent.Info.ArmorImage.Image = v.HelmImage.Value
					script.Parent.Info.Class.Text = "Class: "..v.Class.Value
					script.Parent.Info.PhysicalPower.Text = "Physical Power: "..v.PhysicalPower.Value
					script.Parent.Info.SpellPower.Text = "Spell Power: "..v.SpellPower.Value
					script.Parent.Info.Upgrades.Text = "Upgrades: "..v.CurrentUpgrades.Value.." / "..v.MaxUpgrades.Value
					script.Parent.Info.Health.Text = "HP: "..v.Health.Value
				script.Parent.Choose.Selected.Value = v
					if script.Parent.Choose.Selected.Value.HelmName.Value ~= script.Parent.Choose.HelmName.Value and script.Parent.Choose.Selected.Value.Health.Value ~= script.Parent.Choose.HelmHP.Value and script.Parent.Choose.Selected.Value.PhysicalPower.Value ~= script.Parent.Choose.HelmPhysical.Value and script.Parent.Choose.Selected.Value.SpellPower ~= script.Parent.Choose.HelmSpell.Value then
					script.Parent.Info.Equip.Text = "Equip"
					script.Parent.Info.Equip.BackgroundColor3 = Color3.fromRGB(85, 255, 127)
					elseif script.Parent.Choose.Selected.Value.HelmName.Value == script.Parent.Choose.HelmName.Value and script.Parent.Choose.Selected.Value.Health.Value == script.Parent.Choose.HelmHP.Value and script.Parent.Choose.Selected.Value.PhysicalPower.Value == script.Parent.Choose.HelmPhysical.Value and script.Parent.Choose.Selected.Value.SpellPower == script.Parent.Choose.HelmSpell.Value then
					script.Parent.Info.Equip.Text = "Unequip"
					script.Parent.Info.Equip.BackgroundColor3 = Color3.fromRGB(170,0,0)
					end
			end
		end)
		end
		
	end
end
function refreshchest()
	for i,v in pairs(player.ArmorInventory:GetChildren()) do
		if v:WaitForChild("IsChest").Value == true then
			local button = script.ImageButton:Clone()
			button.Name = v.Name
			button.LayoutOrder = i
			button.Parent = script.Parent.Choose
			button.Image = v.ChestImage.Value
			table.insert(buttons,button)
			button.MouseButton1Click:Connect(function()
				if script.Parent.Choose.Selected.Value == nil or script.Parent.Choose.Selected.Value ~= v then
					script.Parent.Info.ArmorName.Text = v.ChestName.Value
					if v.Rarity.Value == 1 then
						script.Parent.Info.ArmorName.TextColor3 = Color3.fromRGB(109, 109, 109)
					end
					if v.Rarity.Value == 2 then
						script.Parent.Info.ArmorName.TextColor3 = Color3.fromRGB(0, 170, 0)
					end
					if v.Rarity.Value == 3 then
						script.Parent.Info.ArmorName.TextColor3 = Color3.fromRGB(0, 85, 255)
					end
					if v.Rarity.Value == 4 then
						script.Parent.Info.ArmorName.TextColor3 = Color3.fromRGB(85, 0, 255)
					end
					if v.Rarity.Value == 5 then
						script.Parent.Info.ArmorName.TextColor3 = Color3.fromRGB(255, 128, 0)
					end
					script.Parent.Info.ArmorImage.Image = v.ChestImage.Value
					script.Parent.Info.Class.Text = "Class: "..v.Class.Value
					script.Parent.Info.PhysicalPower.Text = "Physical Power: "..v.PhysicalPower.Value
					script.Parent.Info.SpellPower.Text = "Spell Power: "..v.SpellPower.Value
					script.Parent.Info.Upgrades.Text = "Upgrades: "..v.CurrentUpgrades.Value.." / "..v.MaxUpgrades.Value
					script.Parent.Info.Health.Text = "HP: "..v.Health.Value
					script.Parent.Choose.Selected.Value = v
					if script.Parent.Choose.Selected.Value.ChestName.Value ~= script.Parent.Choose.ChestName.Value and script.Parent.Choose.Selected.Value.Health.Value ~= script.Parent.Choose.ChestHP.Value and script.Parent.Choose.Selected.Value.PhysicalPower.Value ~= script.Parent.Choose.ChestPhysical.Value and script.Parent.Choose.Selected.Value.SpellPower ~= script.Parent.Choose.ChestSpell.Value then
						script.Parent.Info.Equip.Text = "Equip"
						script.Parent.Info.Equip.BackgroundColor3 = Color3.fromRGB(85, 255, 127)
					elseif script.Parent.Choose.Selected.Value.ChestName.Value == script.Parent.Choose.ChestName.Value and script.Parent.Choose.Selected.Value.Health.Value == script.Parent.Choose.ChestHP.Value and script.Parent.Choose.Selected.Value.PhysicalPower.Value == script.Parent.Choose.ChestPhysical.Value and script.Parent.Choose.Selected.Value.SpellPower == script.Parent.Choose.ChestSpell.Value then
						script.Parent.Info.Equip.Text = "Unequip"
						script.Parent.Info.Equip.BackgroundColor3 = Color3.fromRGB(170,0,0)
					end
				end
			end)
		end

	end
end

function backpackRefresh()
	for i,v in pairs(buttons) do
		v:Destroy()
	end
	refreshhelm()
	refreshchest()
end

backpackRefresh()

player.ArmorInventory.ChildAdded:Connect(backpackRefresh)
player.ArmorInventory.ChildRemoved:Connect(backpackRefresh)

any help would be helpful thx