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

How to get player name inside a txt label?

I made a script that isnt working but after editing several times, i am on the verge of giving up. This is the script. Its supposed to get a player's name inside a text label. script family tree = startergui.maingui.menubutton.lobby.player1.Name.script

local lobby = game.StarterGui.MainGui.MenuButton.Lobby
game.Players.PlayerAdded:connect(function(player)
    local ch = game.Players:GetPlayers()
    for i = 1, #ch do
        lobby["Player" .. i].Text = ch[i].Name
    end
    for i = #ch + 1, 16 do --clear the unused TextLabels
        lobby["Player" .. i].Text = ""
    end
end)

2 comments

0

Don't give up. I'll fix your code as soon as I can test in studio

0

While this is a duplicate I will attempt to answer

1 answer

✓ Accepted answer

Your question isn't quite clear enough but I'm guessing you're trying to add a players name to ALL of the player's GUI and accessing game.StarterGui won't do that you will have to use

for i,v in pairs (game.Players:GetChildren())
if v.Name == StaterGui then
--continue from here and don't forget to add end in the right spot

I'm also assuming that you want this to happen to each player when they new player enters, as your script works, it will only show it to the player once they die. I also noticed that the player is identified, but never used, so nothing will ever happen with his name. While I don't know how to answer this question at the moment, Those are some things to take into consideration. I would have posted this as a comment but I think there's a limit on characters.

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