#module script vs local vs server
1 messages · Page 1 of 1 (latest)
u can reuse code easily, in the future trust me it wil get complicated
i just started using them too
@cerulean lichen
cant normal scripts do that too?
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
its not like each script is better than the other
they all are for different things and you cant make a game with only one of them
can’t u also use functions in scripts and local globally?
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
Without modules the only way to use a function globally (from other scripts) is with _G, but I highly recommend not doing that.
thats actually really nice you can store functions and data inside a single module
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
🥹 fr ive been using messy tables and reusing code. But are there cons as supposed to local script or server?
like maybe local runs faster? and module script can be accessed by exploiters?
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
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