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

Player's name on to textlabel?

I'm trying to get the player's name on to a textlabel when they first spawn in.

local player = game.Players.LocalPlayer
local plrGui = player.PlayerGui.HealthGui.HealthHud.BorderForHealth.TextLabel

function PlayerNameGoToHealthbar()
	plrGui.Text = player.Name
end

script.Parent.PlayerAdded:connect(PlayerNameGoToHealthbar)

This does nothing...Please help?

3 answers

✓ Accepted answer

This works for me

local player = game.Players.LocalPlayer
local plrGui = player.PlayerGui.HealthGui.HealthHud.BorderForHealth.TextLabel
wait(1)
plrGui.Text = player.Name

3 comments

0

Weird...it doesn't work for me.

0

try adding a wait and make sure this is in a local script in the starterGui folder

0

It worked! Thank you.

I've done these types of TextLabels without the PlayerAdded event before, it seems like that's would you would do but in reality, it's this simple:

local player = game.Players.LocalPlayer
local plrGui = player.PlayerGui.HealthGui.HealthHud.BorderForHealth:WaitForChild("TextLabel")

plrGUI.Text = plr.Name

Also, make sure you WaitForChild for the TextLabel, and make sure the script itself is a LocalScript!

1 comment

0

Don't forget Local Scripts MUST be in either StarterPack or StarterGui!

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