Roblox Lua Wiki
Advertisement

Using GetChildren()[]

Using the call "GetChildren()" is simple. It says what it does. It literally finds and gets the children of a Parent. You can have an argument in it, or leave it blank. Here is an example:


game.Workspace:GetChildren()


Since you have called the function, you can now access it as a table. Giving us the ability to use it like one.

Here is an example of utilizing this function to use it in a loop (even if game.Players:ClearAllChildren() is a better method '<')


p = game.Players:GetChildren()

for i = 1,#p do

p[i]:Remove()

end -- The script removes all players from the game. If you go into a script builder, don't use this.

Advertisement