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

how to get a Frame to get a list of all players in the game?

Asked by 6 years ago

i am trying to make a frame with a list of the player names in it. since the max players is 20, there is 20 text labels named "P"..(Text label number)so like P1, P2,etc. i have a script to get the player names in the game, and set it to ONE of the text labels. instead, it sets a name to all of them. any help?

local frame = script.Parent

while true do
    for i,b in pairs(game.Players:GetChildren()) do

        for  i,v in pairs (frame:GetChildren()) do

            v.Text = b.Name
        end


    end
    wait(5)
end

1 answer

Log in to vote
0
Answered by 6 years ago

Your problem is that you have all of the frames going through the loop for each player.

What you need to do is instead is make it so only one of the frame's text is changed instead of cycling through all of them for each player

local frame = script.Parent

while true do
    for i, b in pairs(game.Players:GetChildren()) do
        frame:GetChildren()[i].Text = b.Name --This makes sure each player name is set to it's own unique frame
    end
    wait(5)
end
Ad

Answer this question