Unequip button not working

Hello, Everybody So I am working on an unequip button for my pet inventory. The unequip button is working fine. It is just I have a block of code in the script that keeps running too much. Like if you spam unequip too much it will mess up the script. Look at the screenshot below. When I kept clicking
Unequip it just kept subtracting. Is there a way to solve this issue
Screenshot 2022-07-14 152316

Local script

local Unequip = script.Parent
local template = script.Parent.Parent.Parent.Parent.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local AmountEquippedValue = game.Players.LocalPlayer.PlayerGui:WaitForChild("Inventory").LowerInvFrame.AmountEquipped.AmountEquippedValue-- Amount of total pets Equipped 
local UnequipPet = game.ReplicatedStorage:WaitForChild("UnequipRE")-- Remote Event for Unequipping the pet


local Inventory = game.Players.LocalPlayer.PlayerGui:WaitForChild("Inventory")
local AmountEquipped = Inventory.LowerInvFrame.AmountEquipped
local amountEquippedValue =  AmountEquipped.AmountEquippedValue 
-- defining the UI




Unequip.Activated:Connect(function()
	
	
	local EquippedValue = template:WaitForChild("EquippedValue")
	EquippedValue.Value = "Unequipped" -- value in template to store info

	template.check.ImageColor3 = Color3.fromRGB(251, 254, 255)-- check mark indicating if a pet is Equipped or not, green if Equipped
	
	for _, child in pairs(template:GetChildren()) do -- checking all children of template
		if child:IsA("StringValue") and child.Name == "PetName" then 
			if child.Value == "Cat" then -- looking for the pet 
				
			
				local CatFolder = Instance.new("Folder")
				CatFolder.Name = "Cat"
				CatFolder.Parent = template 
				
				
				UnequipPet:FireServer(child,char,amountEquippedValue) -- fire the remote event

			end
end
end
		end)


Server Script


UnequipPet.OnServerEvent:Connect(function(player,child,char,amountEquippedValue)
	amountEquippedValue.Value = amountEquippedValue.Value - 1 
	local Cat = char:WaitForChild("Cat") -- Cat as in like the actual model 
	Cat:Destroy()

end)

You could have an if statement that checks if amountEquippedValue.Value is greater than 0, and if so, subtract 1 from it, else, just make the value 0.

I tried it and yes it prevents the value from reaching the negatives, but once you Equip the pet then it is equipped multiple times.