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

Can you assign a parent if you use :Clone?

I am trying to make a script that clones a frame and makes the parent something in starter GUI. On Click function. I am not sure if I can do something like this.

Frame:Clone() Frame.Parent =

3 comments

0

Forgot to mention ''local Frame = script.Parent.Parent.Parent.Parent.Parent.ServerStorage.Data''

0

clone and then Clone.Parent = location

0

local clonedframe = Frame:Clone() clonedframe.Parent = instance

2 answers

✓ Accepted answer

Yes you can, when you clone something it copies the object, but it does not have a parent, meaning you would have to parent it

local Frame = script.Parent.Parent.Parent.Parent.Parent.ServerStorage.Data
local Clone = Frame:Clone() -- clones it
Clone.Parent = -- sets the parent, etc etc

You can also do;

local Frame = script.Parent.Parent.Parent.Parent.Parent.ServerStorage.Data
Frame:Clone().Parent = -- you do not have to make the clone a variable, you can also set the parent from here

Instance:Clone() wiki link: https://developer.roblox.com/en-us/api-reference/function/Instance/Clone

Hope this helps

3 comments

3

why is that a classroom lmao

0

SHSHJSHSJ SORRY LOL I CHANGED IT

--what you'd need to do is something like this:
local Frame = script.Parent.Parent.Parent.Parent.Parent.ServerStorage.Data
local CloneParent = game.--enter desired parent here
local CloneFrame = Frame:Clone()
CloneFrame.Parent = CloneParent

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