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

How to get player name inside a txt label?

Asked by
TrollD3 105
9 years ago

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)
0
Don't give up. I'll fix your code as soon as I can test in studio yumtaste 476 — 9y
0
While this is a duplicate I will attempt to answer BSIncorporated 640 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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.

Ad

Answer this question