A problem with modules

hi, so im learning how to use module scripts but whenever i try to require it, it says it doesnt exist. (this is a serverscript fyi)
image

1 Like

If the ModuleScript is in the same parent as the Script requiring it then this shouldn’t be a problem.

try to waitforchild so It doesnt miss the module before it even loads.

no uh, it still is sadly idk why

is the ModuleScript named “MainModule”?

no, its the default name for a modulescript

ive already tried that, it was the same result sadly

Try renaming it, then requiring it.

Make sure the destination is correct, i.e Script.Parent.MainModule means that the Server Script and MainModule are in the same directory.


still, same result

Could you show your module’s and serverscript’s location in the explorer?
Are you using strictmode?

Are you properly returning the table inside your Module?
If not, then you will not be able to require it.

wdym by using strictmode? im kinda confused

Could you show what’s inside your module?

Don’t use a second localization to require the ModuleScript, that’s redundant.

local Module = require(script.Parent.Module)  

This should be fine.

https://create.roblox.com/docs/luau/type-checking

you just told me to rename it tho in the script-


it didnt work when it was a new module script btw

Your returning a running function, that is the issue.

I am confused.

In certain cases, you can only require a ModuleScript if it’s named “MainModule”, that’s why I said that.

It’s normally a preferable default.

then how could it be fixed? i just followed a tutorial for it