I found this Trello card, which suggests adding a recursive option to :WaitForChild(). Wouldn’t it be more intuitive to simply create a new function, :WaitForDescendant()?
And as long as we’re on the topic, perhaps deprecate the recursive option of :FindFirstChild() and create the new function :FindFirstDescendant()?
How often does one actually use the recursive “FindFirstChild” form? I’m probably hovering around 1% of recursive vs. 99% nonrecursive.
When you’re searching for an object with a given name, you generally know where it’s located. The recursive option seems more like a convenience for people who don’t want to write out a bunch of FindFirstChilds/WaitForChilds.
And I think convenience isn’t the best reason to add a new method. I probably would push to go in the opposite direction (remove the recursive findFindChild) in order to simplify the API, but of course, one shouldn’t remove a feature when people may be using it.
Why clutter the API more when you can just use the second parameter for FindFirstChild()? I think the convenience of the function doesn’t justify why we should add one (or two) more API function(s) when the alternative is simple enough to use.
--FindFirstDescendant
local a = workspace:FindFirstChild('blah',true)
--WaitForDescendant (of course you can counter the inifinity of the loop or frequency if you want)
local a
repeat
wait()
until workspace:FindFirstChild('blah',true)
As for the recursive option for WaitForChild(), I don’t see how I would be using it, but maybe someone else will find a good use for it. It’s just whenever I’m using WaitForChild(), I always run into situations where I know what the parent is.