Is there a way to wait for all children of an instance?

This would be like a Instance:WaitForChildren() that would wait for all the objects of the instance to be loaded to be used

I want to use this to wait every children of services like ReplicatedStorage in the server

1 Like

There is no way to know how many children an instance should have at runtime. You would have to hard-code that number into an attribute on the instance, then await the expected number of children to appear. There is no way to guarantee that the children that load in are the ones you shipped out in Roblox Studio, as any child at all can contribute to decrementing the count.

There is no need for you to do what you’re asking. Just use Instance:WaitForChild normally as you go to access your instances. Furthermore, the server does not need to wait for any instances shipped from Roblox Studio to appear. These instances are guaranteed to exist on the server as that’s where they originate. The client has to await their replication for the fact that the client downloads them from that same server. The only time the server needs to call Instance:WaitForChild is for instances created at runtime, like leaderstats

Another option if you find GetChildren isnt returning everything you expect it to, is to create a ChildAdded event, and just run the same code you were going to run for whatever was in the array.