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

Despite no errors being shown in the output, this script that changes Text isn't working, help?

local TextLabel = game.StarterGui.GameplayGui.PlayerInfo.PlayerName
local Player = game.Players.LocalPlayer
local UserName = Player.Name

game.Players.PlayerAdded:connect(function()
	TextLabel.Text = UserName
end)

This is the entire script.

2 comments

0

So are you trying to make it so when someone else joins, the text box text would change?

0

Yes.

1 answer

✓ Accepted answer

You are changing the text of the textlabel in starter gui, not the one of the player,

local TextLabel = game.StarterGui.GameplayGui.PlayerInfo.PlayerName
local Player = game.Players.LocalPlayer
local UserName = Player.Name

game.Players.PlayerAdded:connect(function()
    TextLabel.Text = UserName--TextLabel is game.StarterGui etc
end)

If you change the startergui one, it will show the players name when they refresh their gui, or when a new player joins, their gui will say the old username

What I think you want to do is change the text of the player that joined textlabel, to do that you would just do this instead,

local TextLabel = game.StarterGui.GameplayGui.PlayerInfo.PlayerName

game.Players.PlayerAdded:connect(function(p)--P is equal to the player who joined
    p.PlayerGui.GameplayGui.PlayerInfo.PlayerName.Text = p.Name--Change the destination of the statements for your own script
end)

Hope this helped, if it did, accept the answer it gives us both rep!

1 comment

0

Thank you! :D

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