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

Getting players names and setting a text label?

Hello, I'm trying to setup a gui type main menu that displays the players username. I cant seem to figure it or find any guides online.

This is what i've got so far.

game.Players.PlayerAdded:Connect(function(plr)	
	script.Parent.Text = plr.Name
end)

4 comments

0

Is it a server script or local script

0

At the moment it's a local script that only the player will see

0

you dont need player added, just define local player in a variable and set player.name to the text of your label

0

That worked perfectly thank you!

1 answer


In a local script, and create a StringValue (physically in the workspace).

local players = game:GetService("Players")
local player = game.Players.LocalPlayer

game.Workspace.StringValue.Value=player.Name

Then in a script inside of the GUI, inside of the textlabel:

script.Parent.Text = game.Workspace.StringValue 

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