Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Clone script wont duplicate model?

Everything works, but it never duplicates. Nothing comes up in output.

wait(2)
script.Parent.Parent.Parent.Enabled=true
workspace.burger.Handle.Anchored=true

function onClick()
	workspace.burger:Clone()
	wait(.1)
	workspace.burger.Handle.Position= Vector3.new(301.87, 7.692, 485.56)
	workspace.burger.Handle.Anchored=false
end

script.Parent.MouseButton1Down:connect(onClick)

1 comment

0

The clone requires a parent, which you never give it. "workspace.burger:Clone().Parent = workspace"

3 answers

Your current script seems a bit messy, let's switch things up to make it look better:

wait(2)
script.Parent.Parent.Parent.Enabled = true
local B = game.workspace:WaitForChild('burger').Handle

B.Anchored = true

script.Parent.MouseButton1Down:Connect(function()
	local CB = B:Clone()
	wait(0.1)
	CB.Position = Vector3.new(301.87, 7.692, 485.56)
	CB.Anchored = false
	CB.CanCollide = true -- make sure it doesn't fall through the world
end)

Now this is much better, assuming this is a local script, it's not good to access parts with a local script. This won't work if you have FE enabled. Now, the thing about your script is if nothing comes up in the output, you have to find where the code stops. So, you add prints.

wait(2)
script.Parent.Parent.Parent.Enabled = true
local B = game.workspace:WaitForChild('burger').Handle

B.Anchored = true
print('1')
script.Parent.MouseButton1Down:Connect(function()
	local CB = B:Clone()
	wait(0.1)
	print('2')
	CB.Position = Vector3.new(301.87, 7.692, 485.56)
	CB.Anchored = false
	CB.CanCollide = true -- make sure it doesn't fall through the world
	print('3')
end)

If all 3 prints, everything ran, meaning that it works. If it doesn't find out what you are doing wrong. Now, I have copied your script, meaning that this was based on your idea. I have helped you make your code better so that it will run smoother. If it doesn't work and doesn't print a part, find the error and post on this post and I will get back to you.

Good luck, I can only help you so far if there is no errors. Wish you luck!

When using :Clone() it must be done within defining a variable like so:

wait(2)
script.Parent.Parent.Parent.Enabled=true

workspace.burger.Handle.Anchored=true

function onClick()
    burger = workspace.burger:Clone()
    wait(.1)
    burger.Handle.Position= Vector3.new(301.87, 7.692, 485.56)
    burger.Handle.Anchored=false
end
	 
script.Parent.MouseButton1Down:connect(onClick)

The reason it is like this is so that the script knows that whenever the object is moved around, an original copy of the object must still be in it's place.

This discussion is preserved as it was. New answers, comments, and votes are closed.