Ok, to start things off I am a complete noob at scripting 100% noob, I'm trying to make a text label that says Hello and your username And I have a screen GUI in the Starter gui and a text label inside of the gui. I don't understand much about scripting so this is what I could piece together from my knowledge Because when I test it, nothing happends and the text label does not change(This is in a local script in StarterGui):
1 | ScreenGui = game.Players.LocalPlayer.PlayerGui.ScreenGui |
2 | ScreenGui.Parent = game.Players.LocalPlayer.PlayerGui |
3 | Textlabel = game.Players.LocalPlayer.Playergui.TextLabel |
4 | Textlabel.Parent = ScreenGui |
5 |
6 | Textlabel.Text = "Hello " .. game.Players.LocalPlayer.Name |
7 |
8 | ScreenGui.Parent = script.Parent |
Thanks!
It's very simple. All you need to do is reference the player and get their name.
Also, you will want to use a Local Script, not a regular script cause a local script only runs in the player and a regular script only runs on the server. And as long as you have a screen GUI with a textlabel inside, you're all set. *If it's in Starter Gui you don't need to say ScreenGui.Parent = game.Players.LocalPlayer.PlayerGui cause that's where it will automatically go.
1 | -- This code would be for a local script inside of a text label. |
2 |
3 | local player = game.Players.LocalPlayer |
4 | local label = script.Parent |
5 |
6 | label.Text = "Hello " ..player.Name |
Simply just do this:
1 | -- Scripts needs to be a local script. |
2 | -- Local scrip must be inside of textlabel. |
3 | label = script.Parent |
4 | plr = game.Players.LocalPlayer |
5 | name = plr.Name |
6 | label.Text = 'Hello ' ..name |