So i've been browsing roblox core gui scripts and found a script with these 2 lines:
local RobloxGui = CoreGui:WaitForChild("RobloxGui") local Utility = require(RobloxGui.Modules.Settings.Utility)
I was confused, they use :WaitForChild() on the RobloxGui, but do not use it on the Utility variable. How does that work? I've been doing a lot of research and i know that WaitForChild waits for the instance and not it's children so why don't they use it on the utility module? Does it have to do something with the point that is it core script or modules replicate like that?
Thanks in advance, kirda
All modules are accessed by calling the require()
function. Utility is a module, so it is required to use that function to access it. However, RobloxGui is not a module, so :WaitForChild()
is used to pause to script until is is in the CoreGui.
Hope this answers your confusion.