Help with Module Scripts

Hello, I have been reading the documentation and learned something but I would like to know from your experience points:

  • What’s a Module Script?
  • What does a Module script do and what is it for?
  • How is it written in code?

I would appreciate it very much if you could give me your answers, experience points to learn much more, thank you very much in advance!

ModuleScript (

Well, module scripts are ways to hold information and store functions. For example, you have over 30 parts in the game, and every time someone touches it you want them to die. To do that you can loop through all the parts in the workspace, then store a function in the module script. Last, you use the touched event and fire the function from the module script. Basically, when you want things to happen repeatedly such as giving rewards to your players, you use module scripts.


Module scripts contain a piece of code that is required (accessed) by other scripts. They are not mandatory, but they allow not having to repeat yourself. This makes scripts shorter and better.


Module scripts created to “support” DRY (stands for Don’t Repeat Yourself) principle, so if u have in your game alot of stuff thats containts script which is repeat the same function, u can put it all in module script and reference module via require built-in method, then just reuse the same function in all scripts, but u keep your code very clear and organized.

This is not only one reason why it was created for in roblox, but this is the main one.


Thank you guys so much! :smiley: