adeep
|
  |
| Joined: 06 Feb 2010 |
| Total Posts: 274 |
|
|
| 10 Dec 2014 11:21 PM |
Code-
-- Chance to be judge is a select few players from game.Players
function BuildEnd() local hint = Instance.new("Hint", game.Workspace) hint.Text = "Prepare to present your builds!" for i = 1, #ChanceToBeJudge do local x = ChanceToBeJudge[i].Backpack:GetChildren() for c = 1, #x do x[1]:Destroy() end end wait(3) hint:Destroy() print("NOT DONE") return end |
|
|
| Report Abuse |
|
|
adeep
|
  |
| Joined: 06 Feb 2010 |
| Total Posts: 274 |
|
|
| 10 Dec 2014 11:23 PM |
| local x = ChanceToBeJudge[i].Backpack:GetChildren() <--- This is nil |
|
|
| Report Abuse |
|
|
|
| 10 Dec 2014 11:27 PM |
What is this 'ChanceToBeJudge'?
Does it mean, a set of table with some randomly selected players? |
|
|
| Report Abuse |
|
|
adeep
|
  |
| Joined: 06 Feb 2010 |
| Total Posts: 274 |
|
|
| 10 Dec 2014 11:28 PM |
| ChanceToBeJudge = game.Players:GetChildren() |
|
|
| Report Abuse |
|
|
|
| 10 Dec 2014 11:38 PM |
How about you replace
for i = 1, #ChanceToBeJudge do local x = ChanceToBeJudge[i].Backpack:GetChildren() for c = 1, #x do x[1]:Destroy() end end
with
for i,Player in pairs(ChanceToBeJudge) do for c,x in pairs(Player:GetChildren()) do x:Destroy() end end |
|
|
| Report Abuse |
|
|
|
| 10 Dec 2014 11:59 PM |
| I'm pretty sure you can't :GetChildren() after a :GetChildren(), which would be pretty sweet. You have to use pairs like @above. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 11 Dec 2014 12:05 AM |
Sure you can, with MTs or index first :)
print(game:GetChildren()[1]:GetChildren()[1].Name);
|
|
|
| Report Abuse |
|
|
|
| 11 Dec 2014 02:35 PM |
| Well, the way you did it, you referenced a specific child with the [1]. You can't reference all of the children of already referenced children using two :GetChilren()'s though, unfortunately. You can select the children of one object at a time though, just not all the objects, which is where a for loop comes in handy. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 11 Dec 2014 02:39 PM |
'Sure you can, with MTs' :) Although you would still use a loop in the MM |
|
|
| Report Abuse |
|
|