How to get the module id anyone know?
i just want make an module script i don’t know the ID of the module
anyone can?
How to get the module id anyone know?
i just want make an module script i don’t know the ID of the module
anyone can?
local ModuleID = (replace with module id)
require:(ModuleID)
Or, if the put the ModuleScript inside of a Script:
require:(script.ModuleScript)
The ModuleID is the path to the module script file. So if your module MyModule is in a folder called Modules inside ServerStorage the ModuleID would be workspace.ServerStorage.Modules.MyModule but you might see developers get the ServerStorage service first rather than use the dotted path something like this:
local ServerStorage = game:GetService("ServerStorage")
local MyModule = require(ServerStorage.Modules.MyModule)
If you have multiple modules in the folder you might capture the folder in a variable to avoid long paths and make code more readable like this:
local ServerStorage = game:GetService("ServerStorage")
local Modules = ServerStorage:FindFirstChild("Modules")
-- local Modules = ServerStorages.Modules would work too
local MyModule = require(Modules.MyModule)
As long as what you pass to require resolves as the path to the module it is a valid id.
I think they’re referring to the asset ID of a ModuleScript uploaded to the Roblox site itself.
Close, but it should be the following, no colon is required.
local moduleId = 0 --change to module id
local module = require(moduleId)
For the original poster, when modules are required in this way (through assets uploaded to the site), the ModuleScript instance itself must be named “MainModule” at the time at which the asset was uploaded (you can update this if necessary), not to be confused with the name of the asset itself which can be name anything.
Possibly, it is not really clear but I took the statement “I just want make an module script…” to mean they meant their own module script. Perhaps they will clarify.
i think like this?
inside another script
local MainModule = game.Workspace.MainModule -- Change the workspace to your main module place
local module = require(MainModule) -- Requires MainModule
print(MainModule) -- This is will printing the module id