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

How to use require?

I seen moderation services use the code require to not view their code how would I do that? Ex:

require(12345)

1 answer

require is what you use to access what a ModuleScript returns. Module/require usage:

--A module script in the workspace

module = {}

function module.add5(number)
	return number + 5
end

function module.print2(text)
	print(text)
end

return module --Return the table of functions

And then

--A regular old script

stuff = require(workspace.ModuleScript)

twelve = stuff.add5(7)
print(twelve)

stuff.print2("sup")

You can then upload that ModuleScript to Roblox, and then use that module's asset ID rather than the ModuleScript's location in your game to use the module.

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