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
 

How do you get the number of objects found...

Previous Thread :: Next Thread 
Tripane is not online. Tripane
Joined: 03 Jun 2011
Total Posts: 11432
15 Jan 2015 04:03 PM
with FindFirstChild?

for _, v in pairs(game.Players:GetPlayers()) do
if v.Character:FindFirstChild("ObjectValue") then

I want to print the number of values found within the players.
Report Abuse
CardboardRocks is not online. CardboardRocks
Joined: 25 Dec 2011
Total Posts: 411
15 Jan 2015 04:07 PM
To get the number of children (or objects found), all you have to do is use this symbol: #

Correct me if I'm wrong or this doesn't work, but try doing

for i, v in pairs(game.Players:GetChildren()) do
numberOfChildren = #v:GetChildren()
end

it should be something along those lines, pm me if that doesn't work and I'll test some things out for you :)
Report Abuse
verbalAKspray is not online. verbalAKspray
Joined: 09 Jul 2014
Total Posts: 23685
15 Jan 2015 04:21 PM
make a variabe like local ayy = 0

then whenever findfirstchild succeeds, make ayy = ayy + 1

then at the end print (ayy)

and for all children amount just do #model:GetChildren()
Report Abuse
cody123454321 is not online. cody123454321
Joined: 21 Nov 2009
Total Posts: 5408
15 Jan 2015 04:24 PM

The # stands for 'length of table.'
So #{1,2,3} would be 3.


Here is one way to use the #.

local Players = game.Players:GetPlayers()
for i=1, #Players do
print(i, Players[i])
end

>> 1 Player

Here is another way.

local Players = game.Players:GetPlayers()
for _, v in pairs(Players)do
print(v.Name, " has ", #v:GetChildren(), " objects.")
end

>> Player has 32 parts.
Report Abuse
025110 is not online. 025110
Joined: 23 Nov 2012
Total Posts: 57661
15 Jan 2015 04:26 PM
for _, v in pairs(game.Players:GetPlayers()) do
if v.Character:FindFirstChild("ObjectValue") then
print(#v.ObjectValue)

not sure
R$6,352
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