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

A really quick question, its only 3 lines of code?

I am trying to get a textLabel to say Welcome back (player name).

For some reason this code isnt working and I am a little lost as to why?

Anyone have any ideas

game.Players.PlayerAdded:connect(function(player)
	script.Parent.Text = "WELCOME BACK" .. player.UserID
end)

Thank you for your time :)

1 answer

✓ Accepted answer

Because your script is a local script inside a gui, there is no need to wait for a player to enter because by the time the local script is running, it is assumed that the player exists. Instead of setting up a listener function to the PlayerAdded event, simply set the property of the LocalPlayer. The fixed code would look like this:

script.Parent.Text = "WELCOME BACK" .. game.Players.LocalPlayer.UserID

In addition you used the UserID property of the player and when judging from the welcome back text, you probably wanted to use the name. In that case, you simply set the Name property instead:

script.Parent.Text = "WELCOME BACK" .. game.Players.LocalPlayer.Name

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