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

How do I make a button on a GUI that clones anything in workspace?

So, I type the workspace object (Baseplate in this case) into the text bar, and then click clone on my GUI, won't work!

Here is the script.

X = script.Parent.Parent.Object
script.Parent.MouseButton1Click:connect(function()
  game.Workspace[X.Text]:Clone()
end)

1 answer

✓ Accepted answer

On line 3, you want to have it FindFirstChild and also set the clone has a variable, like this.

local part = game.Workspace:FindFirstChild(X.Text):Clone()

Then you want to set the parent.

local part = game.Workspace:FindFirstChild(X.Text):Clone()
part.Parent = game.Workspace

If you do this the script should look like this...

local X = script.Parent.Parent.Object
script.Parent.MouseButton1Click:connect(function()
	local part = game.Workspace:FindFirstChild(X.Text):Clone()
	part.Parent = game.Workspace
end)

Hope this helped.

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