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: How to use module script?

Previous Thread :: Next Thread 
Tundradusk is not online. Tundradusk
Joined: 30 Mar 2015
Total Posts: 15
06 Apr 2015 04:48 PM
I open it up and it says

local module = {}

return module



someone told me I can use module scripts to retrieve data from scripts. How do I use it?
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
06 Apr 2015 04:53 PM
You use scripts and retrieve data from module scripts.

http://wiki.roblox.com/index.php?title=Module_scripts

Module scripts are tables that can hold variables and functions. It can be useful for making a Settings script and for making a function available across multiple scripts.
ex.
local module = {
a = "hi"
}

return module

To use a module script in a script (or localscript), you have to use the require() function. From there, you can use the data inside the modulescript.
ex.

local myModule = require(game.Workspace.ModuleScript) --assuming that there's a modulescript in workspace

print(myModule.a) ---> output: hi
Report Abuse
Tundradusk is not online. Tundradusk
Joined: 30 Mar 2015
Total Posts: 15
06 Apr 2015 04:58 PM
Ahh, thank you. Very useful.
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
06 Apr 2015 05:06 PM
you don't have to type in the table

local module = {}

module.Print() = function(text)
print(text)
end

return module


local module = require(module)

module.Print("Hello!")
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
06 Apr 2015 05:07 PM
Whatever works for you
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