I see quire in a few scripts(And I mean very few). What does the require() do? Does it load a link or asset kind like the http getasync()? And how would I use require?
Is it kind like : http://www.roblox.com/Idk-item?id=184517286
?
require(184517286)
--Comment Posted By Gravity Studios.
require
loads a ModuleScript so that you can use the function / object that the script exports.
Here is a ROBLOX blog posts with more articles
Normally, you would pass the ModuleScript to require
, e.g.
helperFunctions = require( workspace.MyModule ) helperFunctions.add( ... blah blah )
I cannot find documentation about the require
that takes a number. I imagine that it runs the ModuleScript uploaded to the particular asset, if the place has permission to insert that script (or maybe in general, since this can be done more or less securely, I'm not sure)
For visibility, Adarkthescoundrel's Comment Below
You can require the assetID of a ModuleScript uploaded directly with the name 'MainModule'
, as long as you have access to that Model (i.e. it's free or you own it.).
A tidbit I found is that any children of the ModuleScript are also included, so you can require the ModuleScript and have access to any kind of ROBLOX Object without having to use the InsertService.