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

How would I clone a TextLabel in a GUI?

Im trying to make a GUI that on click of a button it will clone a textlabel that is in the frame. Im working out the datastore later

3 comments

0

Can you provide the code you attempted?

0

Sure

0

local temp = script.Parent.Parent.ScrollingFrame.TextLabel script.Parent.MouseButton1Click:Connect(function() temp:Clone() end)

2 answers

Connect to the button's MouseButton1Click event.

Next, clone the frame you want.

The reason why the frame you wanted to clone did not appear is because when cloning, the default parent is nil (I assume, at least.)

So, if you want to clone an object and make it appear on screen, you must set the parent in order to make it work.

Step three, is obviously, set the parent.

4 comments

0

What Do I need to add, Im a bit confused.

0

From your old script you sent in the comments of the orginal post, all you just need to do is set the parent. temp:Clone().Parent = path_to_parent

0

OHHH, it works now, BTW, do you know if there is a way for the name to change to something different every time?

0

Well, then you'd need to define the clone. var_name = temp:Clone(); var_name.Name = nameTable[math.random(1, #nameTable)]; var_name.Parent = path_to_parent.

Very simple

local textToclone = game.Workspace.TextLabel --- Set the workspace to wherever the textlabel's original parent is
local clonedtext = textToclone:Clone()
clonedtext.Parent = game.StarterGui.ScreenGui

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