So I was playing natural disaster survival and then I survived the round and it said my name so I wondered how to make a GUI display your name so I did some testing and did not really find an answer. So I came here can someone please answer my question. How do you make a GUI display the players name. It would also be cool if you can help me display some other stuff e.g. some basic math and stuff.
✓ ANSWER ACCEPTED
Player Names and a Gui?
1 answer
✓ Accepted answer
If you want to get the players name have to have a local script and define the local player. Local player means the player you are playing as in the game. This is how you can define the local player:
Local Player = game.Players.LocalPlayer -- Gets the local player
Then if you want to get the name you can do:
Local Player = game.Players.LocalPlayer
repeat wait() until Player -- This waits for the player (basically makes the game wait until everything in the player is loaded)
print(Player.Name)--This will print the players name in the output
Or if you want it in a textlabel do:
Local Player = game.Players.LocalPlayer
repeat wait() until Player
script.Parent.Text = "Hello "..Player.Name-- This will make the textlabel's text say "Hello [Player name]"
If you are using "game.Players.LocalPlayer" you have to use a local script instead of a server script or this won't work
Hope this worked!
This discussion is preserved as it was. New answers, comments, and votes are closed.
