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)
