require(ModuleID) - Error: Unable to find module for asset id

  1. What do you want to achieve?

I want to require a module from the Roblox website and also allow others to use my Module.

  1. What is the issue?

image

https://gyazo.com/512e2d40d7ee144a06e8c1f671a10b98

  1. What solutions have you tried so far?

I followed every solution I could find on the Developer Hub regarding my issue but none of them seem to work.

I hope that the video provides enough detail about my issue. Thank you for reading.

2 Likes

It looks like you’re uploading a regular Script to the module asset. You’ll need to upload a ModuleScript if you want this to work.

2 Likes

Thank you! Oh my gosh I feel so dumb!

Also, does it have to be named “MainModule”? A lot of threads say that is a requirement, but then all my models will be named “MainModule”. Seems like a pain of unorganization.

2 Likes

Only the ModuleScript inside the model needs to be called MainModule. The model asset’s name can be anything.

1 Like

Yes this is the case. The model name (on site) does not need to be MainModule though, it can be anything but the instance itself must be named. My solution to this is to keep my web modules in a Folder instance for organization. Example:
GameModule (Folder) > MainModule (ModuleScript)
I’d then upload the MainModule instance.

1 Like

Is there any way to do this via LocalScript? @realhigbead @Hexcede
image

Yep! You’d need to use InsertService on the server to load the module (as a model). Then you can parent the loaded module somewhere the client can access (e.g. ReplicatedStorage. ReplicatedFirst will not work though since instances only replicate once!) and require it. Note that that means the source code within the module is technically accessible on the client
(through decompilation) however this is unavoidable if you’re running code on the client.

2 Likes