So I have asked this before, and the results were disappointing. I have screengui, with with a frame inside of it, inside that frame is the script, and a textlabel, inside the textlabel are 2 more textlabels(Not necessary for this question). I am trying to have the GUI say the players name the whole time they are on, and only they can see it. Well I have only gotten as far as..
function onPlayerEntered(player) script.Parent.PName.Text = player.Name end game.Players.PlayerAdded:connect(onPlayerEntered)
Some have told me that I needed it to wait until the player was entered..
function onPlayerEntered(player) repeat wait() until player.Character script.Parent.PName.Text = player.name end game.Players.PlayerAdded:connect(onPlayerEntered)
Others have said that name is not a property of player..
function onPlayerEntered(player) local name = player.Character.Name repeat wait() until player.Character script.Parent.PName.Text = name end game.Players.PlayerAdded:connect(onPlayerEntered)
I am so lost, because these all seem like valid reasons but they don't work..
First, Name is a property of Player.
If you're using ScreenGui, you can use a LocalScript to get the LocalPlayer, and thus, their name.
name = game.Players.LocalPlayer.Name