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 » Scripting Helpers
Home Search
 

Re: Grab all players

Previous Thread :: Next Thread 
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
25 Oct 2012 12:14 PM
Wondering how do I grab all players and put them in a table?
Report Abuse
littleAU999 is not online. littleAU999
Joined: 15 Jan 2011
Total Posts: 1375
25 Oct 2012 12:49 PM
local HeresYourTableFullOfPlayers = game:service'Players':GetPlayers()

-- der
Report Abuse
Fedorakid is not online. Fedorakid
Joined: 17 Jul 2010
Total Posts: 7079
25 Oct 2012 12:57 PM
@little, maybe he wants to do something with them? if thats the case OP then:

for _,v in pairs(game.Players:GetPlayers()) do
---stuff, the variable for all the players is v
end
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
25 Oct 2012 01:10 PM

--To access all players

for i,v in pairs(game.Players:GetPlayers()) do
v.Character.Humanoid.Health = 0
end

--To literally put everyone in a table

plrs = {}
for i,v in pairs(game.Players:GetPlayers()) do
table.insert(plrs, v)
end
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
25 Oct 2012 02:24 PM
FOO!

Azerth!!!

:GetPlayers() RETURNS a table...

You are just unpacking the table, then repacking it again.

Inefficiency.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
25 Oct 2012 02:27 PM
players = game.Players:GetPlayers()

print(unpack(players))
Report Abuse
pokemon771 is not online. pokemon771
Joined: 28 Oct 2008
Total Posts: 8671
25 Oct 2012 02:37 PM
Thanks all. :3
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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