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

Any hints on how to get player's name onto a text label?

I have a text label on my custom health bar, and I want the text label to display the player's name when they spawn in. I also noticed that the text label doesn't have a PlayerAdded event, so I'm also trying to figure out how to fire it when players join.

I'm not asking you to write the script out for me, but if you lead me in the right direction then that would be great.

1 answer

✓ Accepted answer

All scripts dealing with GUIs should be local scripts.

So now that you're using a local script, we can get the Local Player,

--Local Script
local plr = game.Players.LocalPlayer

And only the Players Service has the Player Added event.

Now make a variable for the TextLabel,

--Local Script
local plr = game.Players.LocalPlayer
local TextLabel = plr.PlayerGui.ScreenGui.Frame.TextLabel

Now set the text,

--Local Script
local plr = game.Players.LocalPlayer
local TextLabel = plr.PlayerGui.ScreenGui.Frame.TextLabel

TextLabel.Text = plr.Name

Good Luck!

2 comments

0

Thank you!

0

np

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