Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
1
Answered by
xJigoku 17
5 years ago

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.

Ad

Answer this question