Ad
Log in to vote
0

Trying to make a Gui that says the players username?

Asked by
Nimbzee 14
1 year ago

Ok, to start things off I am a complete noob at scripting 100% noob, I'm trying to make a text label that says Hello and your username And I have a screen GUI in the Starter gui and a text label inside of the gui. I don't understand much about scripting so this is what I could piece together from my knowledge Because when I test it, nothing happends and the text label does not change(This is in a local script in StarterGui):

ScreenGui = game.Players.LocalPlayer.PlayerGui.ScreenGui
ScreenGui.Parent = game.Players.LocalPlayer.PlayerGui
Textlabel = game.Players.LocalPlayer.Playergui.TextLabel
Textlabel.Parent = ScreenGui

Textlabel.Text = "Hello " .. game.Players.LocalPlayer.Name

ScreenGui.Parent=script.Parent

Thanks!

2 answers

Log in to vote
1
Answered by 1 year ago
Edited 1 year ago

It's very simple. All you need to do is reference the player and get their name.

Also, you will want to use a Local Script, not a regular script cause a local script only runs in the player and a regular script only runs on the server. And as long as you have a screen GUI with a textlabel inside, you're all set. *If it's in Starter Gui you don't need to say ScreenGui.Parent = game.Players.LocalPlayer.PlayerGui cause that's where it will automatically go.

-- This code would be for a local script inside of a text label.

local player = game.Players.LocalPlayer
local label =  script.Parent

label.Text = "Hello "..player.Name

0
thanks! Nimbzee 14 — 1y
0
Youre welcome suspectshot108 559 — 1y
0
Thanks too, also need it :D Minecrafter09031031 16 — 1y
0
:insert_thumbs_up_here: suspectshot108 559 — 1y
Ad
Log in to vote
0
Answered by 1 year ago

Simply just do this:

-- Scripts needs to be a local script.
-- Local scrip must be inside of textlabel.
label = script.Parent
plr = game.Players.LocalPlayer
name = plr.Name
label.Text = 'Hello '..name

Answer this question