#module script vs local vs server

1 messages · Page 1 of 1 (latest)

cerulean lichen
#

Ive heard people say module scripts are so much better for everything. Some even use it for 99 percent of their script. But I dont get the difference and why its so much better?

vale fulcrum
#

u can reuse code easily, in the future trust me it wil get complicated

#

i just started using them too

#

@cerulean lichen

cerulean lichen
#

cant normal scripts do that too?

maiden sage
#

you can accomplish more in a module script with less code

#

imagine 10 scripts all for a trash system
spawning it
picking it up
recycling it into money

#

that could be 3 scrips

#

but instead you could have 1 module called TrashSystem that handles all of them neatly

#

you can return data from modules
i have npcs with names and money values which i save in a module script that use a function in the module script to get the specific npc i need

#

for instance this is my database module

#

this is my lobby system module

iron breach
cerulean lichen
#

can’t u also use functions in scripts and local globally?

vale fulcrum
#

no

#

only modules

#

@cerulean lichen

#

thats why its good'

#

like you don't have to complicate ur game

#

you just call the module but with different parameters

#

for example

#

if you wanted a chest or something

#

they could all follow the same rule but just give different items

desert sedge
cerulean lichen
#

thats actually really nice you can store functions and data inside a single module

desert sedge
#

Yeah, they’re useful for storing data instead of having massive tables inside your code

#

And ensuring minimal code duplication, so you only need to write the same code once

cerulean lichen
#

like maybe local runs faster? and module script can be accessed by exploiters?

vale fulcrum
#

they have different purposses

#

@cerulean lichen

#

local and server, there are things you have to do on either

#

like u can't get user input on local

manic crest
#

a module script you have to require to use it, like if you are trying to get a table from another script without copy and pasting script in the modulescript, require it, and do something like this