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 a Frame to get a list of all players in the game?

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

✓ Accepted answer

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

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