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

Can you assign a parent if you use :Clone?

Asked by 3 years ago

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 =

0
Forgot to mention ''local Frame = script.Parent.Parent.Parent.Parent.Parent.ServerStorage.Data'' Arkiteckt 38 — 3y
0
clone and then Clone.Parent = location Xapelize 2658 — 3y
0
local clonedframe = Frame:Clone() clonedframe.Parent = instance aceYT1993 0 — 3y

2 answers

Log in to vote
2
Answered by 3 years ago
Edited 3 years ago

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
why is that a classroom lmao sayer80 457 — 3y
0
SHSHJSHSJ SORRY LOL I CHANGED IT Omq_ItzJasmin 666 — 3y
Ad
Log in to vote
0
Answered by 3 years ago
--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

Answer this question