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

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

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

Log in to vote
1
Answered by
6zk8 95
4 years ago
Edited 4 years ago
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.

0
^^ Is very true! PlayerGui is used to define what the player sees! Lightning_Game27 232 — 4y
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? RebornedSnoop 175 — 4y
0
Is there another part of the script? 6zk8 95 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

https://scriptinghelpers.org/questions/104505/how-do-i-change-text-to-players-name

the same thread but solved :) hope it helps

Answer this question