Why some scripts don't load 100% of the time?

When I try testing this section of code I get an error stating that ‘Customisation’ is not a valid member of folder.

local Modules = ReplicatedStorage:WaitForChild('Modules')

local Customisation = require(Modules.Customisation) -- Error here (Line 14)


But when I do prints, it then works and loads the module without question.

local Modules = ReplicatedStorage:WaitForChild('Modules')
print(Modules)
print(Modules.Customisation)
local Customisation = require(Modules.Customisation)


This only occurs when testing online (works fine in studio)

Not this is a module script that’s being called by a LocalScript inside RepFirst. Does it have something to do with loading times?

Can I see your module line 1 to line 14?

I believe the issue is that Modules.Customisation hasn’t loaded into the game yet, so you’ll have to use Modules:WaitForChild("Customisation").

One reason I can think of why it works for when you use print() is because print() takes some time to execute which is probably enough time for Modules.Customisation to load in.
image

2 Likes