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

Trying to make a Gui that says the players username?

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

✓ Accepted answer

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

4 comments

0

thanks!

0

Youre welcome

0

Thanks too, also need it :D

0

:insert_thumbs_up_here:

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

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