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

How to change a textlabel's into a players name?

local plr = game:GetService("Players").LocalPlayer
local name = plr.Name
local change = game.StarterGui.ScreenGui.TextLabel
local player = game:GetService("Players")
player.PlayerAdded:Connect(function()
change.Text = name
end)

Not sure why its not working. I tried it without player added and end) but what I did was print(name) and it actually printed my name so I dont see why it should not work. I suspect its the playeradded part which I made a mistake but I just cant figure out what. Please help thanks!

2 answers

local plr = game:GetService("Players").LocalPlayer
local name = plr.Name
local change = game.plr.PlayerGui.ScreenGui.TextLabel
local players = game:GetService("Players")

players.PlayerAdded:Connect(function()
 change.Text = name
end)

Don't use startergui, after the game loads "startergui" becomes "playergui" in each player. StarterGui is to put GUIs which EACH player will start with. PlayerGui is what a certain player has as their UI.

3 comments

0

^^ Is very true! PlayerGui is used to define what the player sees!

0

plr is not a valid member of DataModel it gives me that error. I tried to resolve it but it doesnt work. The code isnt wrong , so idk why tho is it some other error?

0

Is there another part of the script?

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