How to put cooldown on a Button

hello, devs so i have this inventory but when the player clicks the equip button multiple times the cat will clone multiple but there is only one cat in the inventory. Is there a way so when the player clicks the Equip the cat will only clone one time, but if there is 2 cats in the inventory and the player clicks equip button 2 times then both cats will Equip.

Here is a visual example


as you could see there was only one cat hatched but then that cat cloned 15 times

	local char = player.Character
	local humRoot = char:FindFirstChild("HumanoidRootPart")
	local Cat = BasicEggPetFolder.Cat
	local Clo1 = Cat:Clone()
	Clo1.Parent = char
	while true do 
		wait()
	Clo1:SetPrimaryPartCFrame(humRoot.CFrame * CFrame.new(2,2,2)) 
	end
1 Like

Add a debounce to the script.

local debounce = false

TextButton.MouseButton1Click:Connect(function()
	if debounce then
		wait(5) --waits for 5 seconds
		debounce = false
		return
	end
	debounce = true
	--do whatever you want the button to do
end)
2 Likes