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

How do I receive the player's name?

Asked by
Ulysies 50
8 years ago

I know this is a dumb question, but ive tryed script after script and nothing seems to even slightly work. I'm stumped.. I've got a textlabel in a frame in a screengui, and I need it to say the player's name when they have entered the game and stay there, and all I know how to do is to tag the players name after they have said something in the chat..

function onPlayerEntered(player)
script.Parent.PName.Text = player.Name  
end

game.Players.PlayerAdded:connect(onPlayerEntered)

I understand it doesn't explain who the player is but i'm confused what how to explain it.

3 answers

Log in to vote
0
Answered by 8 years ago

function onPlayerEntered(player)

script.Parent.PName.Text = player.Parent.Name

end

game.Players.PlayerAdded:connect(onPlayerEntered)

I hope this will help you. This is my first time answering a question here so idk if this is the way but you just needed to add "Parent" after player

0
The parent of the "Player" instance is the "Players" instance. The name of the players parent is "Players", sorry ^^ joalars2 107 — 8y
Ad
Log in to vote
0
Answered by
Wutras 294 Moderation Voter
8 years ago
function onPlayerEntered(player)
repeat wait() until player.Character
script.Parent.PName.Text = player.Name
end

game.Players.PlayerAdded:connect(onPlayerEntered)

There is no problem with this script, but are you sure that you placed the script inside the Frame? I still added something that is waiting for the Character to exist as the player perhaps has not loaded.

0
It changed nothing.. Ulysies 50 — 8y
0
Well, as I said. There's nothing wrong with this script. Wutras 294 — 8y
Log in to vote
0
Answered by 8 years ago

There is no "Name" property inside a player. To get the name, you would have to get the name of the character object of the player. So to get the name of the player, do this:

local name = player.Character.Name

Hope this helped.

Your welcome.

0
Sorry that didnt help.. Ulysies 50 — 8y
0
Ok. function onPlayerEntered(player) script.Parent.PName.Text = player.Character.Name end OMEGA27304 8 — 8y

Answer this question