generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: ModuleScript

Previous Thread :: Next Thread 
Francisl4d45 is not online. Francisl4d45
Joined: 14 Aug 2010
Total Posts: 347
14 Dec 2015 11:10 AM
What's the idea behind the ModuleScript? A lot of people find it very useful, but I don't see a point of using it. It's basically a script where you run functions, that's all I know. Why is it so popular?
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
14 Dec 2015 11:11 AM
It is a really clean and modern way of organizing code.
Report Abuse
Francisl4d45 is not online. Francisl4d45
Joined: 14 Aug 2010
Total Posts: 347
14 Dec 2015 11:11 AM
Bump
Report Abuse
Francisl4d45 is not online. Francisl4d45
Joined: 14 Aug 2010
Total Posts: 347
14 Dec 2015 11:13 AM
Can you explain a bit more?
Report Abuse
V0ngola is not online. V0ngola
Joined: 28 Aug 2012
Total Posts: 508
14 Dec 2015 11:19 AM
A ModuleScript is a Script-like object that contains code for a module. Unlike other scripts, a module does not execute when a game starts. The code in a module script can be run by calling the require global function with the ModuleScript as an argument. Its code is executed at the point it is required, and will only be executed once per peer (server/client). If a ModuleScript is required multiple times in the same environment the return value from the first execution will be used for every require call.

When writing code for a large project, you may find yourself defining the same function in several different places. Using module scripts, you can define a function in one place to be used in any number of scripts. This makes maintaining and updating code much easier, as you only have to make changes in one place (as opposed to searching for all the scripts where you use the function).

-http://wiki.roblox.com/index.php?title=API:Class/ModuleScript
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
14 Dec 2015 11:20 AM
Well it is really clean and organized.
You can use it in several ways to organize code.
You can put code in it that can be used in multiple other scripts.
You can make it a free model and the person using it can just use require(ModelId) so it doesn't make their place really messy.
And so forth.
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
14 Dec 2015 11:27 AM
Modular code is very important in development.
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
14 Dec 2015 11:27 AM
So is modular division.
Report Abuse
Francisl4d45 is not online. Francisl4d45
Joined: 14 Aug 2010
Total Posts: 347
14 Dec 2015 11:28 AM
I'm making a Survival game, and I only use LocalScripts and ServerScripts and there are a lot of coding in it. Should I use ModuleScripts and would it make a very big difference?
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image