Selling sells everything?

So I added selling to my game, and its acting very weird. If you sell a mythical, it removes all your legendaries, epics and other mythicals. It’s very buggy. This happens when you have multiple of the same tower in your data.
Heres the local script:

function sellUnit(itemName)
	local tower = getTowerByKey(itemName)
	if tower then
		if tower.Rarity == "Epic" or tower.Rarity == "Legendary" or tower.Rarity == "Mythical" or tower.Rarity == "Exclusive" then
			confirmFrame.Visible = true
			confirmTitle.Text = "Are you sure you want to sell "..tower.Name
			gemsTitle.Text = "For "..tower.SellPrice.." Gems"
			
			confirmYes.Activated:Connect(function()
				local canSell = sellFunc:InvokeServer(itemName)
				if canSell then
					playerData = canSell
					updateItems()
					confirmFrame.Visible = false
				end
			end)
			
			confirmNo.Activated:Connect(function()
				confirmFrame.Visible = false
				sellingUnits = false
				sellButton.Text = "Sell Units"
			end)
		else
			local canSell = sellFunc:InvokeServer(itemName)
			if canSell then
				playerData = canSell
				updateItems()
			end
		end
	
	end
end

And the server script:

sellUnitFunc.OnServerInvoke = function(playerWhoSell,itemName)
	print(playerWhoSell,itemName)
	local shopItem = getTowerByKey(itemName)
	local playerData = data[playerWhoSell.UserId]
	if shopItem and playerData then--if it exists and player has some data
		if shopItem.Name ~= "Ninja Cameraguy" and shopItem.Name ~= "Supreme Cinemaguy" and shopItem.Name ~= "Big Scientist Cameraguy" and shopItem.Name ~= "Speakergal" and shopItem.Name ~= "Cameraguy" then
			
			local towerToRemove = table.find(playerData.OwnedTowers, itemName)
			
			if towerToRemove then
				table.remove(playerData.OwnedTowers, towerToRemove)
				playerData.Gems += shopItem.SellPrice
				local removeSelected = table.find(playerData.SelectedTowers, itemName)
				if removeSelected then
					table.remove(playerData.SelectedTowers, removeSelected)
				end
			end
			
			
		print(data[playerWhoSell.UserId].OwnedTowers)
		replicatedStorage.GuiInteract:FireClient(playerWhoSell)
		updateEvent:FireClient(playerWhoSell, data[playerWhoSell.UserId].Gems)
			return playerData
		elseif shopItem.Name == "Ninja Cameraguy" or shopItem.Name == "Supreme Cinemaguy" or shopItem.Name == "Big Scientist Cameraguy" or shopItem.Name == "Speakergal" then
			errorEvent:FireClient(playerWhoSell,"Error","Can't sell gamepass towers!")
		end
	else
		warn("Tower/player data does not exist")
	end
	return false--if something went wrong
end

I’m really confused on why it’s selling all copies if I’m not looping through. Any help is really appreciated, thanks!

Honestly when doing a deleting system for multiple items or multiple copies, I make it as a table (which you do, but not sure if its done correctly),


{
 Name = "Example", -- Name of the "Tower"
 Amount = 1 -- This way we can call the table then just -= 1 it
}

This allows us to just call the with Table.Amount -= removeAmount
This just makes it way easier than having a bunch of instances or smth stacked up in the table and have to sort through each one

But everyones data is already just a bunch of string values. And sometimes, when you remove one, it removes all?