Does waitforchild(“model”) wait until all children of the model are loaded?
Well yes, waitforchild(“Model”) waits for the model as total, so then all the children of the model should be loaded as well
Another quick question, how do I get rid of this stupid chat window?
https://gyazo.com/917cd82346490bac78f46c1bdf5ef8f6
It blocks the entire view, and I see no button to turn it off.
There should be the chat icon in the top bar like always i think? unless you messed with the startergui while testing
There isn’t, and I didn’t mess with any GUI except for my own which does not affect any other GUI’s.
Hmm, weird, could you go into test and show me a screenshot of your explorer window (mainly the bottom part of explorer)
I restarted my client tests and it works now. Must of been some bug.
Okay, good, Good luck further on your game!
Wait for child,Waits for child specific so it only waits until the model has loaded it isn’t sure that all child of Model are loaded or not for eg
game.Players.LocalPlayer:WaitForChild("leaderstats").Cash
Can also give error sometime because of Cash not loaded
THIS IS TOTALLY A EXCEPTIONAL CASE AND HAPPENS WHEN CLIENT RUNS BEFORE SERVER SCRIPT FINISHES THE CHANCES OF THIS ERROR HAPPENING IS RELATIVELY LOW
I’ve had my script error 1/3 times so far. Perhaps I’ll just add a wait on the server script for loading purposes.
Is there some sort of preloading mechanism that exists that can load all models in a game?
You need to wait on every line
game.Workspace:WaitForChild("Model"):WaitForChild("stuff")--and so on
What if I have like 30 parts inside one model, is there a way to loop through it?
You could do
repeat wait() until #model:GetDescendants() == expecteddescendants
Till i know you need to wait only when game has started like in pre function,So if you are doing some late or after some time then there isn’t a need of wait for child you can also just add these lines at 1st in every script
repeat wait() until game:IsLoaded()
or
game.Loaded:Wait()
You can also use Index method:
So what you’re saying is that if I just wait a few seconds it’s guaranteed to load?
Well No i mean you should wait until all object are loaded in either way i would highly prefer @index_nil way though
I don’t believe this is correct, otherwise (for example) doing game:WaitForChild("Workspace")
may yield until the entire workspace had loaded with all descendants, which is not the behaviour.
Roblox instances are streamed in from a top-down model - i.e. if you have a model with 20 parts, and 1 part has a Light inside of it, the model will load, then the 20 parts, then last the Light will load in. It would not be safe to do workspace:WaitForChild("Model").LightPart.Light
.
Edit: Useful post to clarify this for you
That isn’t true, if you wait for just the Model
it will only wait for the existence of that Model
to appear, it doesn’t care about its children.
Can you please remove that answer as a solution? Because it isn’t true, WaitForChild("Model")
does not wait for all the model’s children to be loaded.
Handling misinformation one step at a time, no it does not.