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: Is there a code to find how many of a certain part there is?

Previous Thread :: Next Thread 
wrightracer3n is not online. wrightracer3n
Joined: 09 Nov 2011
Total Posts: 964
22 Jan 2014 09:32 PM
Hello and thanks for viewing this. I was wondering if there was a certain piece of code that could tell you or find how many of a certain part (with the same name) there is.

If you could direct me towards a Wiki link or let me know of the code, that'd be helpful! :D

Thanks,
WrightRacer3n
Report Abuse
ElectricAxel is not online. ElectricAxel
Joined: 15 May 2009
Total Posts: 16239
22 Jan 2014 09:38 PM
function count(name, where)
local amount = 0;
for i, v in pairs(where:children()) do
amount = amount + count(name, v);
if v.Name == name then
amount = amount + 1;
end
end
return amount
end

count("Brick", workspace) --example usage
Report Abuse
wrightracer3n is not online. wrightracer3n
Joined: 09 Nov 2011
Total Posts: 964
22 Jan 2014 09:42 PM
Thanks! :D I appreciate it!
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