Do you need to wait for child if the parent is loaded?

If I had a sound inside a script. Would I need to do this?

local sound = workspace:WaitForChild(“Script”):WaitForChild(“Sound”)

Or if I already did 'WaitForChild(“script”) be enough, does that function load all child content?

Or would this be fine?
local sound = workspace:WaitForChild(“Script”).Sound

Yes, you do need to wait for children. Each instance loads on it’s own.

If “Script” is the same script you’re writing the code in, you don’t need to index it with workspace:WaitForChild() because it is automatically a keyword “script”. In this case, you’d write

local sound = script:WaitForChild(“Sound”)
2 Likes

Sorry I wrote this completely wrong.

If I have that sound inside the script I’m working on. And do

script.Sound
I still need to have a wait for child?

1 Like

Not necessarily if the script has previously yielded from execution.

1 Like

You don’t need to, but I suggest doing so as it is better to be safe, and any performance impacts will be negligible.

if the parent has loaded then no, you dont have to wait again.
Instances in roblox are loading in “descending” order (aka children load before parents).

local sound = script.sound
No need for any WaitForChild for a few reasons.