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

How would I clone a TextLabel in a GUI?

Asked by 5 years ago

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

0
Can you provide the code you attempted? GoldAngelInDisguise 297 — 5y
0
Sure Trooper_Toaster 0 — 5y
0
local temp = script.Parent.Parent.ScrollingFrame.TextLabel script.Parent.MouseButton1Click:Connect(function() temp:Clone() end) Trooper_Toaster 0 — 5y

2 answers

Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
5 years ago
Edited 5 years ago

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.

0
What Do I need to add, Im a bit confused. Trooper_Toaster 0 — 5y
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 Fifkee 2017 — 5y
0
OHHH, it works now, BTW, do you know if there is a way for the name to change to something different every time? Trooper_Toaster 0 — 5y
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. Fifkee 2017 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

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

Answer this question