Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can i make script do a deep search?

Asked by
NexeusX 137
7 years ago

O'k so i have a "Folder" called Library in my game, that is in my ServerStorage, anyway i have multiple Folders Inside of Library, which all have specifically named items. So i have a script that will use the FindFirstChild() function to look for a child in the script. But if i keep adding more and more folders within folders of stuff, how can i make a script Find the Child in those deeper folders?

1 answer

Log in to vote
1
Answered by 7 years ago

Not many people know that the FindFirstChild() function actually has two parameters: the name of the object you're looking for and whether or not the search is recursive. Since the recursive parameter defaults to false, you want to set it to true:

MyHouse:FindFirstChild("Bike",true) --My bike is in the garage, not just the house, so I need to use recursion to find it.

I hope this helped!

Sources: ROBLOX Wiki: API:Class/Instance/FindFirstChild

Ad

Answer this question