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

How to make a text label set to local players name?

It's going to be a single-player game and I'm trying to make the surface GUI on a door be set to local players name but it isn't working

local player = game.Players.LocalPlayer.Name

script.Parent.Parent.TextLabel.Text = player

1 comment

0

Can you include your script?

1 answer

✓ Accepted answer

If its a single player game you can just get all the players in the game(1) and chose the first player(you), so it might look like this

local players = game.Players:GetPlayers()
surfaceGui.TextLabel.Text = players[1].Name

5 comments

0

would this go into a script inside the surface gui?

0

if you put this inside the surface gui you would slightly tweak it to look like 'script.Parent.TextLabel.Text = players[1].Name'

0

that is what i did but it seems to not work for some reason as a server script and there are no errors

0

you can't use LocalPlayer in a server script.

0

it still doesn't work in a local script

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