Can someone explain the uses and a example script? Thanks! ( the script icon looks like a normal script with a part beside it )
ModuleScripts are used to extract and isolate repeatedly used sections of code, the aim of which is to reduce server load when applicable, and to reduce the code you have to edit when you want to change something.
The way they work is, for the Server and each Client, when first require
ed, the ModuleScript will run once like a normal Script running, and then return a Table. On subsequent require
s, the table returned the first time is returned again. The contents of this table can be anything, and is most typically a list of functions that you are intending to share between your objects.
This allows you to create 'Modules' (hence the name) that your Scripts and LocalScripts can use.
For example, if I wanted to give something Health and a Healthbar, I could give them a Health Module, which would have functions for damaging, healing, and showing/hiding the HP bar. If I wanted them to have AI, I could give them an EnemyAi Module, which in turn could require
additional modules based on the actions you need to have it do.