So when a new player joins I was hoping for it to put the players name on the text box, What am I doing wrong? Should it be local?
function onPlayerEntered(newPlayer) print("First stage") script.Parent.Name1.Text = "Player:" p.Name = "" print("Second stage") end game.Players.ChildAdded:connect(onPlayerEntered)
Put this in a LocalScript.
game.Players.PlayerAdded:connect(function() print("First stage") script.Parent.Name1.Text = "Player:" ..game.Players.LocalPlayer.Name.. "" print("Second stage") end)
function onPlayerEntered(newPlayer) print("First stage") script.Parent.Name1.Text = "Player:".. newPlayer.Name --All you needed to do was put .. to contract the string. print("Second stage") end game.Players.ChildAdded:connect(onPlayerEntered)
If you'd like to set Name1.Text to the player's name upon join, prefixed by "Player: " you will need to use the '..' operator.
function onPlayerEntered(newPlayer) print("First stage") script.Parent.Name1.Text = "Player: "..newPlayer.Name --joins the string 'Player: ' with the name of the new player print("Second stage") end game.Players.ChildAdded:connect(onPlayerEntered)