I hear is is basicly a place to store a function to use in other scripts, but that's all I know. How do I use module scripts? I don't understand what the wiki means about them...
Think of Module scripts as scripts with functions that can be used anywhere. I use them in most of my games, and inside of them I include functions that I will constantly be using throughout the development of a game. For example, lets say that I am making a game that constantly counts down from a certain number:
MyModuleScript:
local functions = {} functions.countDown = function(start) for i = start,0,-1 do print(i) end end) functions.countUp = function(finish) for i = 0,finishdo print(i) end end) return functions
Instead of constantly having to write that function, you would just call the one from your module script
Script somewhere in your game:
local functions = require(game.Workspace.MyModuleScript) --Whatever you named the Module script would be what's inside the parentheses --You can name "functions" whatever you want functions.countDown(5) print("------") functions.countUp(5)
The output would be:
5 4 3 2 1 0 ------ 0 1 2 3 4 5
Module scripts are super helpful for big games that repeat a lot of tasks. If you have any questions feel free to ask!
Modulescripts are simple. ModuleScripts do not function like normal scripts do. Instead they can be called using the require() function. Here's an example using ModuleScripts:
local module = {} --This code is inside the modulescript in the workspace function module:Test() print("1-2-3 Test!") end return module
--In Script in serverscriptstorage local Module = require(workspace.ModuleScript) Module:Test() --> 1-2-3 Test!
If this didn't help, more info can be found here.