If I have for example this tree…
… and I run …
local myFolder = workspace:WaitForChild("Folder1")
… does this mean
WaitForChild will wait until
Folder1 and ALL ITS CHILDREN will also be loaded?
Or do I have to write a
WaitForChild for EACH CHILD, one by one?
I’m pretty sure that when a container loads (like a Folder that’s containing objects), the children also load right after, so there’s no need for a WaitForChild for the children.
Yeah that works, but if you want to get all descendants of the folder you need to write:
local myFolder = workspace:GetDescendants("Folder1")
But in this case you are right, myFolder is the folder with everything inside
Sorry, but after spending some time developing my game, I realized that WaitForChild doesn’t wait for all its children.
I had a single
playerGui:WaitForChild("ScreenGui") and I expected all its children to be properly loaded after this command.
It worked for a while, but after adding some children items, Roblox began to report errors, as if that item did not exist.
WaitForChild to these children items, Roblox correctly recognized them.
So the truth is:
WaitForChild will NOT wait for all children and you have to use one
WaitForChild for each children you want to use inside your code.
When I replied to you I assumed you already knew it wouldn’t wait for all children because it is litteraly called “WaitForChild” not “WaitForChildren”. I didn’t exactly know what you tried to achieve but in that case you are right. WaitForChild is only for one item and not for all children in that folder