How do I make a textlabel display the players username?

No the line player.PlayerGui doesnt work unless i use Player:WaitForChild(“PlayerGui”)

Perhaps Its because I always load in late as my PC is old

I think I see the issue here, you placed it in StarterPlayerScripts and not StarterCharacterScripts.

image
I tried them all, no cigar.

I place my UI scripts inside the gui components and of course local scripts

Was AFK, but this should work.

repeat task.wait() until game:IsLoaded()
local GUI = game:GetService('Players').LocalPlayer.PlayerGui.ScreenGui
GUI.TextLabel.Text = game:GetService('Players').LocalPlayer.Name

game:GetService('StarterGui') is more of a replicatedstorage type thing
game:GetService('Players').LocalPlayer.PlayerGui is what is being displayed currently

1 Like

It is just because people like me load late into the game so playergui will not be a component in that time

Did not work.

  19:55:14.056  Baseplate auto-recovery file was created  -  Studio
  19:55:21.504  usrname is not a valid member of ScreenGui "Players.TillLindemann156.PlayerGui.ScreenGui"  -  Client - LocalScript:3
  19:55:21.504  Stack Begin  -  Studio
  19:55:21.504  Script 'Players.TillLindemann156.PlayerGui.ScreenGui.console.command.usrname.LocalScript', Line 3  -  Studio - LocalScript:3
  19:55:21.504  Stack End  -  Studio

Same happened when using GUI.TextLabel.Text

did you spell the component in screengui correct?

What component you might be talking about?

Literally how, I could open studio and test this right now and it’ll work.
And what is usrname, that’s not proper syntax nor is it a property.

The ‘usrname’, Is it spelt correct just like that or is it ‘username’?

1 Like

It is the textlabel, but renamed.

Yes, it is indeed usrname.

Show us your screenGui and everything inside so we can have a clear idea what we are looking at.

So the problem you are having here is that you don’t know how to change the path directory to fit the one that you have in your game and instead you copy and paste the code without changing it at all to adapt to it. Let me try again:

local Player = game.Players.LocalPlayer
local PLAYERGUI = Player.PlayerGui
local TextLabel = PLAYERGUI.ScreenGUI.console.usrname

Copy it letter to letter, if this doesn’t work then please tell me what is the classname of the script you’re currently editing. Is it script or localscript? Because I just realised that your script is literally called ‘script’ which may be a server-sided script and not a client-sided one.
obraz

Would you like to give me the hierarchy of your gui?
image

I will publish the game under FOSS, please hold.

Would you like to give me the hierarchy of your gui?
image
My apologies for the light mode, I have a feeling that I might be using an outdated version of studio.

repeat task.wait() until game:IsLoaded()
local GUI = game:GetService('Players').LocalPlayer.PlayerGui.ScreenGui
GUI.console.command.usrname.Text = game:GetService('Players').LocalPlayer.Name
local Player = game.Players.LocalPlayer
local PLAYERGUI = Player.PlayerGui
local TextLabel = PLAYERGUI.ScreenGui.console.command.usrname

I put the script her for you 30char limit

local GUI = game:GetService("Players").LocalPlayer.PlayerGui:WaitForChild("
ScreenGui")
GUI.console.command.usrname.Text = game:GetService("Players").Name

Alternatively,

local Label = script.Parent
Label.Text = game:GetService("Players").Name

This isn’t hard at all, why does it feel like im deciphering a complex radian math equation.

1 Like