As a Roblox developer/scripter, it is currently hard to use WaitForChild in an efficient manner for complex or deeply-nested UI elements.
For example, one of my UI handlers when needing to modify text in a UI element may look like this:
local PriceLabel = script.Parent:WaitForChild("Products"):WaitForChild("DoubleCash"):WaitForChild("Info"):WaitForChild("PriceLabel")
PriceLabel.Text = "example"
Whilst I could (and often do) format it differently like this:
local ProductsFrame = script.Parent:WaitForChild("Products")
local DoubleCashFrame = ProductsFrame:WaitForChild("DoubleCash")
local DoubleCashInfo = DoubleCashFrame:WaitForChild("Info")
local PriceLabel = DoubleCashInfo:WaitForChild("PriceLabel")
This takes up a lot of room in a script, and often the shallower UI elements aren’t used for anything - they’re just used in this chain of WaitForChild and then never touched again.
I think it would be beneficial if developers had the option to specify a fuller path (relative from the starting UI object on which you call WaitForChild) as such:
local PriceLabel = script.Parent:WaitForChild("Products.DoubleCash.Info.PriceLabel")
This way, it’s one-line, doesn’t take up as much width on the screen as the first option, and doesn’t create a bunch of one-use variables that occupy names I could potentially want for other variables.
I do however realise this could cause potential backwards compatibility issues for if a game has a UI element who’s name is something like “Frame.Products” but I’ve personally never seen it - though no doubt this is done at least somewhere on the platform. Perhaps a different method could be added like WaitForDelimited or WaitForPath.
Speaking of WaitForPath, there is a community-made module for this already, called WaitForPath, which is an okay solution but I believe it would be of great benefit for most developers if this was native behaviour in the engine.
Thanks for taking the time to read.