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

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

Asked by 8 years ago
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.

0
So are you trying to make it so when someone else joins, the text box text would change? Nickoakz 231 — 8y
0
Yes. Strykebyte 45 — 8y

1 answer

Log in to vote
1
Answered by
xuefei123 214 Moderation Voter
8 years ago

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!

0
Thank you! :D Strykebyte 45 — 8y
Ad

Answer this question