If I have something like this, do I need to use WaitForChild(), for example, to get UiSound in the local script?
Thanks!
If I have something like this, do I need to use WaitForChild(), for example, to get UiSound in the local script?
If you initiate it from ReplicatedFirst/StarterGui (and have script regarding that here)?
No; No need to.
WaitForChild() should only be used if the Parent (not ancestor) of the instance you’re trying to access might change during runtime. Since the LocalScript and UiSound are under a common/unchanging parent, you shouldn’t have to.
If you ever get an error where you’re “attempting to index nil” or some instance “is not a valid member of” another, you should still save WaitForChild as a last resort.
TL;DR: Nope, and try your best to avoid it.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.