Clones cant double when clicked

Im trying to make a thing where you click a part, it clones and doubles it. also everypart can be doubled too. for example if i click part #1 then i will get Part#1 and Part#2, i can also click part#2 to get Part#3 and 4, the doubling goes on when the player clicks the clones or original part. this is the code and idk whats wrong

local part = workspace.Part 
local clickDetector = part:FindFirstChild("ClickDetector")

local function clonePart()
    local clone = part:Clone() 
    clone.Parent = workspace
    clone.Position = Vector3.new(math.random(-100, 100), math.random(0, 20), math.random(-100, 100)) -- Set a random position for the clone
    clone.Anchored = false

    clone.ClickDetector.MouseClick:Connect(clonePart) 
    print("Part cloned successfully!")
end

if clickDetector then
    clickDetector.MouseClick:Connect(clonePart) -- Initial cloning when the part is clicked
else
    print("ClickDetector not found on the part.")
end

Wheres it placed?

Hey mate! Here’s the corrected version of your localscript:

local part = workspace.Part 
local clickDetector = part:FindFirstChild("ClickDetector")

local function clonePart()
    local clone = part:Clone() 
    clone.Parent = workspace
    clone.Position = Vector3.new(math.random(-100, 100), math.random(0, 20), math.random(-100, 100)) -- Set a random position for the clone
    clone.Anchored = false
    clone.ClickDetector.MouseClick:Connect(clonePart) 
         print("Part cloned successfully!")
    end)
end

clickDetector.MouseClick:Connect(clonePart) -- Initial cloning when the part is clicked

Pretty sure you replied to the wrong person lol

My apologizes for the wrong pin. I meant to 46_231, Gulp.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.