Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

What does require(ID)(soemthing) mean in a module?

i saw this script and it did

require(someID)(data)

i have been wondering how i can do this with a module i have tried

require(moduleScript)(data)
--in a different script
return function(data)
end

but it didnt work, please help

1 answer

✓ Accepted answer

The "ID" part of it comes from a published module script. They upload the module script to Roblox and use the number in the module's link like an audio to run it in their game.

I'm unfamiliar with the "data" part, but I think it runs a function inside the module script with "data" as an argument.

Here's an example of how it works:

Script:

local Module = require(script.Parent.TestModule)("Test") -- Requires module and and puts an extra parenthesis to run the function. "Test" is an argument.

Module Script:

local function TestFunction(data) -- Note that we put "Test" as an argument, so data = "Test"
	print(data) -- Prints "data"
end

return TestFunction -- The module returns the function, so requiring the module actually gives the function itself.

Hope this helped! If you have any questions, just comment!

This discussion is preserved as it was. New answers, comments, and votes are closed.