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

ModuleScript Assets unable to require?

Asked by
Lualogy 30
8 years ago

Hello, When i was working with Modules lately, I attempted to upload the ModuleScript to the ROBLOX Site, therefore allowing the usage of private modules. However when i renamed the ModuleScript to 'MainModule' and updated it to the site as a model, as i tried to require the module using its assetid. My original code isn't as simple as this, but it still failed to work like the following.

Here is a code example of the situation:

Inside the ModuleScript

local test = {}

function test:add(x, y)
    return x + y
end

return test

Inside the Script

local library = require(378772246) -- This is the assetId of the module
print(library:add(1,2)) -- It didn't print anything or error in the output

Edit: I have placed the script in ServerScriptService.when the module is placed in-game and required, the function fired, but not from an asset.

0
Have you tested it on a ROBLOX server? Using require() on an assetid will not work within studio. NullSenseStudio 342 — 8y
0
I have tested in a Game Server, however it still doesn't work. Lualogy 30 — 8y
0
I guess you actually can require an asset from studio, though the wiki page on private modules said you couldn't... Anyway, if it didn't print or error then I think there must be something causing your original module to yield for a long time. Does it use the wait function or WaitForChild method on anything before returning? NullSenseStudio 342 — 8y
0
it doesn't use any wait function to yeild Lualogy 30 — 8y

1 answer

Log in to vote
0
Answered by
Kurieita 125
8 years ago

From my knowledge and experiences, I believe that requiring a module by it asset ID only work on a live server. Meaning both play solo and test server will not work.

I remembered that I had too upload the the module to the place while testing.

A easy way around this is to either do as I said. Upload the module and remove when done.

local Module = require(Workspace.Module) --require(00000)

Or do what I like to do is load the module with InsertService.

Another note that you should keep in mind that users are allow to require lock module and it is very easy to see the source of them. I done it before.

Loading a module using InsertService is prob as secure as it get.

Ad

Answer this question