Lem0nzzz
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 521 |
|
|
| 30 Apr 2015 06:25 PM |
Could someone explain to me the use of them, and maybe suggest me some tutorials that would help me guide my way through, so I'll learn more about them? I already read the wiki, not understanding the meaning.
~ I approve 4 hats instead of 3!!! |
|
|
| Report Abuse |
|
|
Lem0nzzz
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 521 |
|
|
| 30 Apr 2015 06:28 PM |
What are module scripts, and what do you need them for? And how would you use one?
~ I approve 4 hats instead of 3!!! |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2015 06:28 PM |
--ModuleScript,Workspace,Name="StuffFunc" function stuff(blah) return blah end
return stuff --//
--Script,Workspace stuff=require(workspace.StuffFunc) print(stuff()) --// |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2015 06:29 PM |
Their useful if you want to create a less laggy gun, since the bullets are controlled via server script, and not local.
~who's awesome? you're awesome! |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2015 06:29 PM |
say you have this function in a module script:
function hi() print("hi") end
you have 10 scripts that need that function but it'll be too tedious to add, so what do you do? module scripts allow you to define the function in one place and use it in any script |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2015 06:29 PM |
| They're used so you don't have to type the same variables, functions, etc. in a bunch of different scripts. |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2015 06:30 PM |
| I use it for my CET/CEST clock, so when the summertime changes I don't have to update all my scripts, just one Module. |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2015 06:30 PM |
Yes that too, they also work with FilteringEnabled to prevent exploiters.
~who's awesome? you're awesome! |
|
|
| Report Abuse |
|
|
97neko
|
  |
| Joined: 14 Sep 2014 |
| Total Posts: 16159 |
|
|
| 30 Apr 2015 06:31 PM |
MODULE SCRIPT:
local stuff = {}
stuff.Test = function(arg) print(arg) end
stuff.Test2 = function(arg) print(arg..'2') end
return stuff
OTHER SCRIPT: local module = require(game.Workspace.ModuleScript) module.Test('fart') module.Test2('fart')
OUTPUT:
fart fart2
"whos ruinable" -Codite |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2015 07:16 PM |
"since the bullets are controlled via server script, and not local." Wrong and misinformed.
"they also work with FilteringEnabled to prevent exploiters." You could not be more wrong here. |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2015 07:19 PM |
"Their useful if you want to create a less laggy gun, since the bullets are controlled via server script, and not local."
They add functions to the code you require it in, it isn't server unless you require with a server script. |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2015 07:20 PM |
It's good for organization, and re-using code. You could use _G and get nearly the same results.
But.
If you require() a ModuleScript on a machine, it always returns the same value for THAT machine. So if you say, have an Interpolation function in ReplicatedStorage; both Clients and the Server and require() this and use it. All one script, easy to edit.
I use it for the first sentence at the top of this post. |
|
|
| Report Abuse |
|
|
|
| 30 Apr 2015 07:21 PM |
both Clients and the Server (can) require()
Mistake, and I use it as well for this. |
|
|
| Report Abuse |
|
|