Please note: I have read through the modulescripts docs I have made sure the Modulescript is name MainModule etc.
I have also used basic debugging to check the functions, for example print('1')
I have a module script that uses script.Disabled = true / false etc.
As you can see below the scripts.
The functions work they just don’t enable the scripts.
But if i require the model within the game, they work fine, but if i require the module out of the game none of the scripts enable, But functions within the module work.
why would you do that though.
just have an main script that calls modules scripts that handles what ever you want to do so you can call them whenever you want.
Hey @foundanerror! I’ve done this as it’s for multiple of people to use so I can update them / fix bugs amonst the loops etc, without them having to replace the asset.
I am confused about what you just said. Please explain further. You would able to do the exact thing you are trying to do with and modular architecture. Its way better for organizing and debuging your code trust me. I use to do the same thing you are doing now. If you need help maintaining that structure i recommend you try using knit as it helps maintain an modular flow. Knit | Knit
You shouldn’t even be disabling scripts and enabling scripts in the first place. thats bad practice, as I said you should use module scripts to handle those functions and what you want to do
Correct me if I’m wrong, but when requiring a module by id it can’t access its children. I believe it works as a independent piece of code outside the hierarchy.
I’m still testing, it might be because scripts can’t run from nil, which is probably the parent of the module code’s container (if it has one).
Try adding print(script.Parent), if it’s nil then you’ll want to reparent the scripts to Workspace or ServerScriptService in your code when setting disabled to false.
Okay, I’m pretty sure this is the problem. Scripts basically only run when ancestors of ServerScriptService or Workspace (some exceptions like tools). Your module is in Workspace or ServerScriptService, but when you require by id its parented to game.Model, where scripts don’t run. (if you’re curious, you can do something similar by parenting your module to ServerStorage, then notice how that causes the same problems as requiring by id)
All you need to do is at the start of your code move the loops folder to ServerScriptService, then reference it from a variable. You can also move the individual scripts to ServerScriptService or Workspace too.
So basically, you need to move your scripts to ServerScriptService or Workspace to have them run.