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: Find all children with the same specific name

Previous Thread :: Next Thread 
superICH3 is not online. superICH3
Joined: 25 May 2010
Total Posts: 4729
06 Sep 2016 09:45 PM
I want to find all models in workspace that have the name "Tree". I am having trouble accomplishing this. If I do :FindFirstChild("Tree") it only detects the first model named tree.

If someone could guide me, that would be great.


Report Abuse
superICH3 is not online. superICH3
Joined: 25 May 2010
Total Posts: 4729
06 Sep 2016 09:57 PM
?


Report Abuse
instawin is not online. instawin
Joined: 04 Jun 2013
Total Posts: 8777
06 Sep 2016 10:05 PM
1. create a table to put all of the found tree models into
2. use a for loop to iterate through the children of workspace
3. add each tree to the list

local function getTrees()
local trees = {}

for index, child in pairs(workspace:GetChildren()) do
if child.Name == "Tree" and child.ClassName == "Model" then
table.insert(trees, child)
end
end

return trees
end

local trees = getTrees()
print(#trees)
Report Abuse
superICH3 is not online. superICH3
Joined: 25 May 2010
Total Posts: 4729
07 Sep 2016 03:25 PM
thanks


Report Abuse
ScripterJohn13 is not online. ScripterJohn13
Joined: 01 Jan 2010
Total Posts: 5658
07 Sep 2016 03:57 PM
Or use a while loop as long as:

Workspace:FindFirstChild("Tree",true)

Rename the tree and add to a table then
Repeat... The true parameter tells the method to find trees that are also models of anything under the workspace node.

Afterwards you can choose to change all the trees names back or whatever..
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