Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years ago

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
0
Can you include your script? Spjureeedd 385 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

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
0
would this go into a script inside the surface gui? Fervantpigeon47 31 — 4y
0
if you put this inside the surface gui you would slightly tweak it to look like 'script.Parent.TextLabel.Text = players[1].Name' jediplocoon 877 — 4y
0
that is what i did but it seems to not work for some reason as a server script and there are no errors Fervantpigeon47 31 — 4y
0
you can't use LocalPlayer in a server script. killerbrenden 1537 — 4y
0
it still doesn't work in a local script Fervantpigeon47 31 — 4y
Ad

Answer this question