Ive been wanting to use lightning libraries such as EvLightning and Electric Arcs but im not sure how to call them/use them.
How to use a roblox library / modules?
1 answer
In roblox, or Lua 5.1 for that matter, a library(or module script if using roblox) is essentially used through a require(), which is equivalent to #include in some programming languages. Essentially here's how it works, when you run require(ModuleScriptHere), it outputs the table(or any value if you really want...) that it returns at the bottom. If we consider this as just a normal table, it proves as a useful tool for storing large arrays of data, especially ones with thousands of elements in it. Normally this itself is useful, but the real value of this is the fact that one can actually store functions inside a table as well, which one can them call on by requiring the table where they are stored. Essentially, you'd have a table within a module script, such as local FunctionThingaroos = {}. If you do function FunctionThingaroos.Whatever() and define a function below, it essentially allows you to call upon it from the table you required. Here's a quick example:
Module Script:
local FunctionThings = {}
function FunctionThings.DoWhatever()
--Run code
end
return FunctionThings
Server Script(or local script):
local ModuleToUse = require(ModuleScriptFromBefore)
ModuleToUse.DoWhatever() -- Runs the code inside FunctionThings.DoWhatever()
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Thank you