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

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

Asked by
Probix 80
7 years ago

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

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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!

0
Thank you! Probix 80 — 7y
0
np User#11440 120 — 7y
Ad

Answer this question