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

How do I make a player's name appear on a TextLabel?

Asked by 3 years ago
Edited 3 years ago

I tried using this script but I feel like it's outdated.

script.Parent.Text = game.Players.LocalPlayer.Name

I don't know what I'm doing wrong, do I have to change the code or set the TextLabel's name to something else?

3 answers

Log in to vote
0
Answered by 3 years ago

if ur using a script you need at least a remoteevent or something that returns the players name if ur using a localscript ur code is perfect

--hab a good day
Ad
Log in to vote
0
Answered by
Ghost40Z 118
3 years ago

You need to put this code in a localscript since it is the only type of script that can access PlayerGui and the Player itself.

local player = game.Players.LocalPlayer
while wait() do
    script.Parent.Text = player.Name
end

This script will constantly update the label with the player name. Let me know if it doesn't work.

0
I tried putting it in a localscript but it still doesn't work. Boomer_Hazard 0 — 3y
Log in to vote
0
Answered by 3 years ago

What you have to write is

script.Parent.Text = game.Players.LocalPlayer.Humanoid.DisplayName

i went from the script you gave but this should work. i also fixed it from last time but try this!

Answer this question