Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Show local player's name in textlabel?

Hello, I'm making a profile gui and I need the local player's name to replace the textlabel text. I got this script that goes inside the gui but doesn't work:

local player = game.Players.LocalPlayer
local gui = game.StarterGui.leftmain

game.Players.PlayerAdded:connect(function()
gui.nameframe.TextLabel = game.Players.LocalPlayer.Name
end)

game.startergui.leftmain = where the gui is gui.nameframe.textlabel = nameframe is the frame and textlabel is where the username should go but it doesn't work, any solutions?

2 answers

✓ Accepted answer

Use PlayerGui, not StarterGui. What the player sees on their screen are descendants of their player guis.

local player = game.Players.LocalPlayer
local GUI = player:WaitForChild('PlayerGui'):WaitForChild('leftmain')

GUI.nameframe.TextLabel.Text = player.Name
--This should be in a local script inside of your text label
local Player = game.Players.LocalPlayer
local gui = Player:WaitForChild("PlayerGui",1):WaitForChild("leftmain",1) -- this is your gui
local TextLabel = gui:WaitForChild("nameframe",1):WaitForChild("TextLabel",1)

repeat wait() until Player.Character
TextLabel.Text = game.Players.LocalPlayer.Name

-- this may be what you needed.. If not tell me otherwise

This discussion is preserved as it was. New answers, comments, and votes are closed.