I have been reading up on ModuleScripts recently and I'm still trying to figure out exactly how they work. I read the Wiki ModuleScripts and Module Scripts Tutorial pages but I still don't fully understand how I would use one or when it would be appropriate to use one. I am inexperienced with ModuleScripts so maybe somebody else knows how to explain this to me.
A ModuleScript is an object that gives the ability to create a reusable library of code. ModuleScripts are called using the function 'require()', and must always return something. Anything returned can be used within the script that called require() on it, and any number of scripts can do so. You'd likely use a ModuleScript to create a library usable by both Client and Server.
Here is an example of how to use one:
ModuleScript:
local library={ foo=(function() print("bar") end) } return library
Script:
local Module=require(PathToModule) print(Module.foo())
Output: bar
Locked by FearMeIAmLag, Muoshuu, and M39a9am3R
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?