How to insert a GUI with a TextLabel using Scripts?

How do I insert a GUI & TextLabel using only scripts?

Simply using"TextLabel",Parent)

Change the parent to which ever you want to parent it

For Everyone:

for _, players in pairs(game.PlayersGetPlayers() do
local NewText ="TextLabel", players:WaitForChild("PlayerGui"):WaitForChild(Your UI)

For one user:

local NewText="PlayerGui",game.Players:FindFirstChild(Username):WaitForChild("PlayerGui):WaitForChild(Your Ui))

How do I create a UI and put the TextLabel in using ONLY scripts, tho?

Could you elaborate? I believe i did it correct but the example i gave is server sided script so.

If client:

local NewText ="TextLabel", script.Parent--[[To Ui]])

Yes, have the script create a ScreenGui too.

It’s desame just change “TextLabel” to “ScreenGui”.

Could you possibly type a script in here that does both so I can understand it better?

for _, players in pairs(game.PlayersGetPlayers() do
local NewGui ="ScreenGui", players:WaitForChild("PlayerGui")
local NewText ="TextLabel", NewGui)

(im sorry i did something wrong, i doubled the for loop)

We haven’t heard anything from you yet.

Are you having trouble? Tell us so we could furthermore assist you!

Did you fix it? If so solution my answer so people at the future are able to solve they’re problem.

You should never use the second argument of because its not performant, instead parent it without the argument.

This is only the case if the instances’ other properties are being assigned.

As a general rule of thumb it’s a good practice to follow though.

1 Like

If he’s not gonna assign any properties of it, then he can just directly do .Parent on it

local NewText ="TextLabel", NewGui)
local NewText ="TextLabel").Parent = NewGui

These lines would essentially have the same performance as one another.

1 Like

Oh so I don’t need .Parent if I’m not gonna assign any properties in it right?

This script doesn’t work. I tried editing it to fix it but nope.