How to stop pet from infinitely cloning

Hello everybody, I have a script that detects if a player clicks equip then a cat should duplicate, but the issue is that the cat will not stop cloning. Is there any way that I could edit the script so the cat will duplicate it once? What could I lose, I think debounce might work, comment your suggestion.

Here is the script
LOCAL SCRIPT

local Equip = script.Parent
local template = script.Parent.Parent.Parent.Parent.Parent




Equip.MouseButton1Click:Connect(function()
	Equip.Text = "Equipped"
	
	local EquippedValue = template:WaitForChild("EquippedValue")
	EquippedValue.Value = "Equipped"

	for _, child in pairs(template:GetChildren()) do 

		if child:IsA("Folder")	then 
			if child.Name == "Cat" then 
				print(child)
				
				if EquippedValue.Value == "Equipped" then 
					
				

				local ReplicatedStorage = game:GetService("ReplicatedStorage")
				local EquipPet = ReplicatedStorage:WaitForChild("EquipPet")
					
				
					EquipPet:FireServer()
					
				else 
					print("Pet is already Equipped")
				end 
				end
			end
		
	end



end)

SERVER SCRIPT

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local EquipPet = ReplicatedStorage:WaitForChild("EquipPet")

EquipPet.OnServerEvent:Connect(function(player)
	local Cat = game.ReplicatedStorage.Pets.BasicEggPets.Cat:Clone()-- where the cat clones
	local char = player.Character or player.CharacterAdded:Wait()
	Cat.Parent = char
end)

1 Like

This statement doesn’t make sense to me? :slight_smile: You don’t change the EquippedValue.Value after the pet got equipped, so yes, it will fire again.

2 Likes