generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Put all players in a table?

Previous Thread :: Next Thread 
FallenTacoz is not online. FallenTacoz
Joined: 05 Aug 2013
Total Posts: 328
12 Mar 2016 10:15 PM
Hello, I'm fairly new to tables. Anyone know how to gather all players and put them in a table? Please help!


Report Abuse
malachi11 is not online. malachi11
Joined: 07 May 2008
Total Posts: 2420
12 Mar 2016 10:16 PM
game.Players:getChildren()

That returns a table of all the children in Players.
Report Abuse
Wayne_Gretzky is not online. Wayne_Gretzky
Joined: 03 Apr 2008
Total Posts: 78011
12 Mar 2016 10:17 PM
There's a convenient method for that, game.Players:GetPlayers()

It'll give you the table of every Player within game.Players.

You can use :GetChildren() to do the same with any other object

https://youtu.be/L78yVFeyvRo?t=31
Report Abuse
FallenTacoz is not online. FallenTacoz
Joined: 05 Aug 2013
Total Posts: 328
12 Mar 2016 10:18 PM
Thank you all, but I would want insert them into a table. Like table.insert?


Report Abuse
malachi11 is not online. malachi11
Joined: 07 May 2008
Total Posts: 2420
12 Mar 2016 10:19 PM
GetChildren() or GetPlayers() already returns a table. You don't need to insert them into one.
Report Abuse
FallenTacoz is not online. FallenTacoz
Joined: 05 Aug 2013
Total Posts: 328
12 Mar 2016 10:21 PM
Okay. Thanks! I want to make a game with "rounds". And whenever someone dies, it takes their name out of the table. Can I do that with GetChildren()?


Report Abuse
foreverpower is not online. foreverpower
Joined: 05 Feb 2011
Total Posts: 5578
12 Mar 2016 10:22 PM
^
getChildren is deprecated, GetChildren should be used instead.

Also, GetChildren returns all objects, not just players. For this purpose, GetPlayers should be used.
Report Abuse
Wayne_Gretzky is not online. Wayne_Gretzky
Joined: 03 Apr 2008
Total Posts: 78011
12 Mar 2016 10:39 PM
It returns a table, so you can do everything you normally would with it
When a player dies, find them in the table and you can run table.remove() on it to remove them from your table
Report Abuse
FallenTacoz is not online. FallenTacoz
Joined: 05 Aug 2013
Total Posts: 328
12 Mar 2016 10:40 PM
How can I set it as a variable?


Report Abuse
foreverpower is not online. foreverpower
Joined: 05 Feb 2011
Total Posts: 5578
12 Mar 2016 10:41 PM
The same way you set any other variables:

local players = game.Players:GetPlayers()
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image