How do I make a textlabel display the players username?

I tried this, but it does not work. I literally do not have a single idea how to run this.

TextLabel.Text = PlayerInstance.Name

Simple.

game:GetService("Players").LocalPlayer.Name
or
tostring(game:GetService("Players").LocalPlayer)
1 Like

Use This

TextLabel.Text = game.Players.LocalPlayer.DisplayName

UserName

TextLabel.Text = game.Players.LocalPlayer.Name

Neither of them worked.

sssssss

Worked for me, is this a localscript or a serverscript?

A localscript, it’s inside the textlabel that corresponds for teh players’ username

Gem of a nickname. Anyway, I think here’s how you should do it:

local Player = game.Players.LocalPlayer
TextLabel.Text = Player.Name

If there are any errors please log them here.

  19:34:17.682  Baseplate auto-recovery file was created  -  Studio
  19:34:24.858  Players.TillLindemann156.PlayerGui.ScreenGui.console.command.usrname.usrname:2: attempt to index nil with 'Text'  -  Client - usrname:2
  19:34:24.859  Stack Begin  -  Studio
  19:34:24.859  Script 'Players.TillLindemann156.PlayerGui.ScreenGui.console.command.usrname.usrname', Line 2  -  Studio - usrname:2
  19:34:24.859  Stack End  -  Studio

It appears that it doesn’t see the textlabel. Have you defined it? If not, then you should define it by writing its path directory, for example, if the textlabel is under StarterGui.playergui.screengui.console.command and is called ‘usrname’ then you should define it as follows:

local TextLabel = game.StarterGui.PlayerGui.ScreenGui.console.command.usrname
  19:38:09.015  Baseplate auto-recovery file was created  -  Studio
  19:38:13.718  PlayerGui is not a valid member of Players "Players"  -  Server - Script:1
  19:38:13.718  Stack Begin  -  Studio
  19:38:13.718  Script 'Players.TillLindemann156.PlayerGui.ScreenGui.console.command.usrname.Script', Line 1  -  Studio - Script:1
  19:38:13.718  Stack End  -  Studio

It was used as an example, please don’t use it literally. Where is the textlabel located at? Alternatively, you can send us the file of your place where your textlabel is.

My text label is located at StarterGui/ScreenGUI/console/usrname, with usrname being the textlabel. The script is located under usrname.

Sending the file won’t be possible because of hardware limitations, but if you really need to I can publish the game and leave it FOSS.

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

try this

  19:45:08.166  Baseplate auto-recovery file was created  -  Studio
  19:45:12.799  Players.TillLindemann156.PlayerGui.ScreenGui.console.command.usrname.Script:2: attempt to index nil with 'PlayerGui'  -  Server - Script:2
  19:45:12.800  Stack Begin  -  Studio
  19:45:12.800  Script 'Players.TillLindemann156.PlayerGui.ScreenGui.console.command.usrname.Script', Line 2  -  Studio - Script:2
  19:45:12.800  Stack End  -  Studio

Could this happen because there isn’t such a thing such as playergui?

it’s playerGui not PlayerGui, roblox is case sensitive.

PlayerGui hasnt loaded in yet so it bugs out instead use:

local Player = game.Players.LocalPlayer
local playerGUI = Player:WaitForChild("PlayerGui")
local TextLabel = playerGUI.ScreenGUI.console.usrname

Negative. It’s not because it hasn’t loaded in, it’s because he wrote “playerGUI” as “PlayerGUI”. The latter has its ‘P’ capitalised, and “ui” in lower case, making it a new and undefined variable.

Well It still bugs for me, when I don’t use waitforchild

Perhaps it is because the textlabel here you tried to define does not exist in the directory you provided it with. Are you sure that you have the following directory:

"playerGUI.ScreenGUI.console.usrname"

?