I have a feeling I screwed up on Line 3 at the end. Can someone help me edit it? Thanks :)
game.Players.PlayerAdded:connect(function(player)
Username = player.name
game.Players.LocalPlayer.PlayerGui.PhoneGUI.Menu.Owner.Text = (Username)
end)
I have a feeling I screwed up on Line 3 at the end. Can someone help me edit it? Thanks :)
game.Players.PlayerAdded:connect(function(player)
Username = player.name
game.Players.LocalPlayer.PlayerGui.PhoneGUI.Menu.Owner.Text = (Username)
end)
Let's look at two scenarios.
1.) Using a local script
2.) Using a regular script
One issue with your code is that you can't use LocalPlayer and .PlayerAdded in the same script due to the simple fact that one only works in server-scripts and one only works in localscripts.
If this is a localscript, we can make the code to:
local plr = game.Players.LocalPlayer;
local name = plr.Name;
repeat until plr.ChildAdded:wait().Name == "PlayerGui"
plr.PlayerGui.PhoneGui.Menu.Owner.Text = name;
In a regular script, we can do the following:
game.Players.PlayerAdded:connect(function(plr)
local name = plr.Name;
plr.PlayerGui.PhoneGui.Menu.Owner.Text = name;
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
5 comments
Take away the () near Username.
Tried that
Is this within a LocalScript? If so, that is your problem; According to the WIKI, the 'PlayerAdded' event does not work in a LocalScript anymore.
If it's a regular script use player.PlayerGui.PhoneGUI.Menu.Owner.Text = Username. If it's a local script do game.Players.LocalPlayer.PlayerGui.PhoneGUI.Menu.Owner.Text = game.Players.LocalPlayer.Name and remove the PlayerAdded.
Also, in the original script ,
player.nameshould beplayer.Name.