I have a ‘Main’ script, with multiple module scripts that are all childs of Main. However, I am struggling because they are on the same thread so can’t be ran at the same time. I know there are ways for me to work around this, but I was wondering if there was a simple solution? I tried doing coroutine.create(require())
but this gives me an error because I have it set up so it returns 1. Any ideas?
1 Like
If you want them all to run at the same time, you can try either task.spawn
(if it needs to be absolutely immediate) or task.defer
(if it’s okay for it to not run immediately)
Example usage:
local Main = nil -- your main module
for i,v in pairs(Main:GetChildren()) do
if v:IsA("ModuleScript") then
task.defer(function()
require(v)
end)
end
end
Alternatively, you can still use coroutines:
coroutine.wrap(function()
require(v)
end)()
2 Likes
… I feel a little bad, that was very obvious. OOPS
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.