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

Player's name on to textlabel?

Asked by
Probix 80
7 years ago

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

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

This works for me

local player = game.Players.LocalPlayer
local plrGui = player.PlayerGui.HealthGui.HealthHud.BorderForHealth.TextLabel
wait(1)
plrGui.Text = player.Name
0
Weird...it doesn't work for me. Probix 80 — 7y
0
try adding a wait and make sure this is in a local script in the starterGui folder tigergo4 83 — 7y
0
It worked! Thank you. Probix 80 — 7y
Ad
Log in to vote
2
Answered by 7 years ago
Edited 7 years ago

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!

0
Don't forget Local Scripts MUST be in either StarterPack or StarterGui! TheHospitalDev 1134 — 7y
Log in to vote
-1
Answered by 7 years ago

Are you using a Local Script?

0
Yes, and it's working now. Probix 80 — 7y

Answer this question