Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Require Module script Children?

Asked by 5 years ago
Edited 5 years ago

Okay so I've been looking into modulescripts and I get the use of them, how to use require and all that. My only question is can I call a function from a modulescript within the MainModule using require(assetid) ? If so how because when I do require it returns the error saying the modulescript I am looking for is nil. Sorry about not providing any sourcecode rn, about to head out and figured I'd ask this real quick and get back to it.

Pretty much what I have is: MainModule>FireMagics(ModuleScript inside MainModule) I tried testing by using a print cmd just to see if it was working, mod = require(assetid) mod.FireMagics.Print("Success") . And the Print function is just a basic print(msg).

When I use require, does it not retrieve the children of MainModule and if does how do I access them?

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
5 years ago

I don't know if I got you right, but I'm assuming you want your MainModule to require a module parented to it.

So, first of all, make sure the module is a child of MainModule (like on this picture)

Now, if you want your MainModule to use that module, just use

require(script.ModuleScript)

or

require(script:WaitForChild("ModuleScript"))

in your MainModule.

(obviously replace ModuleScript with the name of your module)

0
This worked perfectly, thank you! Would have never thought of it tbh. OneTruePain 191 — 5y
Ad

Answer this question