|
| 17 Jun 2014 01:28 PM |
game.Players.ChildAdded:connect(function(child) print(child.Name) update() end)
game.Players.ChildRemoved:connect(function(child) print(child.Name) update() end)
function update() local plrs = game.Players:GetPlayers() for i = 1,#plrs do for i,v in pairs(plrs[i]:WaitForChild('PlayerGui'):WaitForChild('ScreenGui'):GetChildren()) do if v:IsA('TextLabel') then v:Destroy() end end local plr_label = script:WaitForChild('TextLabel'):Clone() plr_label.Parent = plrs[i]:WaitForChild('PlayerGui'):WaitForChild('ScreenGui') plr_label.Position = UDim2.new(1,-205,0,15+(i*25)+5) plr_label.Name = plrs[i].Name plr_label.Text = plrs[i].Name end end
So it works, but it only shows the player's name, no one else's. I know the problem is because of the for loop/function, but I can't seem to fix it. I just can't think straight today.
Thanks! |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2014 01:29 PM |
I just glanced at it, but you might want to use ipairs() instead of pairs() in this case...
What's the error you're getting?
-The [Guy] |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2014 01:32 PM |
No error. It works, but it only shows my name, not anyone else's.
EX:
players:
Player1
Player2
Player1's PlayerGui:
Player1 --player2 should be here
Player2's PlayerGui:
--player1 should be here Player2 |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
| |
|
| |
|
| |
|
Stefan631
|
  |
| Joined: 23 Dec 2010 |
| Total Posts: 1350 |
|
|
| 17 Jun 2014 05:39 PM |
What's the difference between pairs and ipairs? Can they be used interchangeably? |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2014 05:46 PM |
ipairs in order, treats as array in pairs not in order |
|
|
| Report Abuse |
|
|
| |
|
| |
|