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: game.Players question.

Previous Thread :: Next Thread 
BenJoodles is not online. BenJoodles
Joined: 04 Dec 2012
Total Posts: 90
31 May 2013 04:14 AM
So, after I do:

game.players:getchildren(). (I know capitalisation, but my phone is messing up) how can I find each players character using in pairs.
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
31 May 2013 04:19 AM
I'd first use :GetPlayers() so that it finds players and not everything inside players (stated in roblox wiki also)
Then I could use this to get the players and their characters:

p = game.Players:GetPlayers()
for i = 1, #p do
if p[i].Character then
--Stuff goes here
end
end
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
31 May 2013 04:22 AM
Or if you wanted to use pairs:

for _,v in pairs (game.Players:GetPlayers()) do
if v.Character then
--Stuff goes here
end
end
Report Abuse
BenJoodles is not online. BenJoodles
Joined: 04 Dec 2012
Total Posts: 90
31 May 2013 04:42 AM
What does #p and [i] mean?


I know what the p is and I know what the i is. I jut don't know what the [] an # mean.
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
31 May 2013 04:46 AM
The for loop with i and #p is for the loop to run through every player.
When using p[i].Character, it runs the for loop in every player to find a character in each and ignores any players with no character.
Report Abuse
BenJoodles is not online. BenJoodles
Joined: 04 Dec 2012
Total Posts: 90
31 May 2013 08:02 AM
Yes, in this situation, but what do they do? Like an explanation of the actual thing, not jut this scenario.
Report Abuse
BenJoodles is not online. BenJoodles
Joined: 04 Dec 2012
Total Posts: 90
31 May 2013 08:20 AM
bump

Thou Signature Hither
Report Abuse
BenJoodles is not online. BenJoodles
Joined: 04 Dec 2012
Total Posts: 90
31 May 2013 09:06 AM
Nevermind. Sorted. :)
Report Abuse
Oysi is not online. Oysi
Joined: 06 Jul 2009
Total Posts: 9058
31 May 2013 09:12 AM
[ Content Deleted ]
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