Part gets cloned twice when called once

For some reason, I’ve realized that part of a script of mine keeps cloning a part and mesh it’s meant to only clone once.

I’ve tried a few fixes to get this to work to no prevail.

Below I’ve put the script that isn’t working correctly and screenshot to show what I mean

local function setUp(char)
	local handle = fx.Handle:Clone()
		handle.Parent = char
		local m6d ="Motor6D", handle)
		m6d.Part0 = char["Right Arm"]
		m6d.Part1 = handle
		m6d.C1 =,.125,0)
		local chance = math.random(1,20)

		local model = fx.Mesh:Clone()
		model.Parent = handle
		local  weld ="Weld", model)
		weld.Part0 = handle
		weld.Part1 = model
		weld.C1 =,-1.7,0) * CFrame.Angles(math.rad(90),0,math.rad(-90))


Add a debounce.


where is setUp() being called?

There’s nothing wrong with your function, it is something to do with your code that is using that function. But you could also add a checker if that object or the handle already exist.


local function Setup()
    -- If the handle already exists, then don't do anything.
    if char:FindFirstChild("Handle") ~= nil then return end


local isDoneCloning = false
local function Setup()
    -- If the value of isDoneCloning variable is true, then don't do anything.
    if isDoneCloning then return end
    isDoneCloning = true

This is what confused me the most.

I had originally tried this but nothing in the script had changed.

This wouldn’t work, it generates 2 at the same time; it doesn’t repeat it self.

Would be better if you could give us more context other than the code you’ve provided. Just like what I said, it is something to do with your code that is using that function.

I was looking to give you more context and I had come across these lines of text

for i,v in pairs(game.Players:GetChildren()) do
	repeat wait() until v.Character
		char:WaitForChild("Right Arm")
		char:WaitForChild("Right Arm")

I must’ve accidently written them at different times not realizing that I had already made the first one before hand. That was just a oversight on my end

These both do the same thing, calling the function twice.

1 Like

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