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

How do I change the text of this text label?

game.Players.PlayerAdded:Connect(function(plr)
	wait(1)
	game.StarterGui.StarterGui.PlayerName.Text = game.Players.LocalPlayer.Character.Name
end)

I've tried so many different things to change it, but it never worked. I'm using a local script because I'm trying to make a loading screen GUI kind of.

4 comments

0

And where did you put the LocalScript? Also, I don't think using PlayerAdded event in a LocalScript is a good way to do.

0

I put it under the gui.

0

I'm not quite sure you can change startergui... Hm..

0

Make a remote event.

3 answers

✓ Accepted answer

Try puting this local script in your screengui:

local player = game.Players.LocalPlayer --Using PlayerAdded is deprecated, user LocalPlayer instead.

player.PlayerGui.[Your ScreenGui name].PlayerName.Text = player.Name

You should try:

game.Players.PlayerAdded:Connect(function(plr)
    wait(1)
    game.StarterGui.StarterGui.PlayerName.Text = game.Players.LocalPlayer.Name
end)

Else you should add a waitforchild function at the startergui

3 comments

0

It didn't work.

0

And I don't know how to make a waitforchild function because I am not really that good at scripting. I'm still trying to learn.

0

Don’t see the problems?

Put the localscript inside the text

local player = game.Players.LocalPlayer
local text = script.parent

text.text = player.name

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