Greetings!
I am sorry if this looks extremely easy but it’s almost 4 am and i really want to finish this.
Up to the point, i want so a Label’s text located in a part to change to the local player’s name.
For an example , if in a server there is player A and player B , the first one will see his name in the text label, while the player B will see his name.
Script used :
local playerservice = game:GetService("Players")
local player = playerservice.LocalPlayer
local Playertext = script.Parent
player.CharacterAdded:Connect(function()
wait()
Playertext.Text = player.Name
end)
Located in the part’s text label as a Local Script.
Define a function before character added, for example,
function PlayerAddedName()
Playertext.Text = player.Name
end
player.CharacterAdded:Connect(PlayerAddedName())
I just wrote this in notepad so there’s probably some errors but you should get the gist
my guess is your problem is that the scripts not loading in enough time for the character to be added, so it won’t work in solo games, this should fix it
If you’re making the local script a descendant of the part, and the part is in Workspace, you will have to move the script because it only works under a few instances:
I would put the local script in StarterPlayerScripts and then resolve its path to the label from Workspace. After that, your local script should be running correctly.
Why do you have it connected to a .CharacterAdded? Wouldn’t it be easier to just do it once because it doesn’t seem like it changes later? Also you need to move the script to StarterPlayer because local scripts do not work in workspace.
The .CharacterAdded function seems redundant. Just replace the entire function with “Playertext.Text = player.Name” as it should be able to immediately detect the player + its name and then set the TextLabel’s Text to the name.
Please read what OP is asking for instead of replying to solutions stating This is obvious.
While it may be obvious for you, it does not apply for everyone else on the DevForum.