I have some really bad code to create all the bullets for each player’s gun in a game I’m working on. Because each weapon has a lot of settings that make it unique, the old code sends a lot more across the RemoteEvent than it needs, and often overflows the 50kb bandwidth between client and server. I have thought of a possible solution, but I want to make sure it isn’t just as bad before I waste tons of time making a broken solution work.
What happens when potentially dozens or hundreds (over the lifetime of the server) of copies of a ModuleScript get cloned and then required by the server script that processes bullet events?
I guess the main thing I don’t know is how other scripts interact with ModuleScripts. such as:
-
Yes Modules are only run once, yes scripts that require() them later can use them much like a function. But, do scripts store a reference (like a BindableFunction might) to these modules, or is it something something with more intimate access to the code itself?
-
If two instances of a module have identical code, is each one run when it is created or does it refer back to the original Module’s code?
-
If a previously-required module is destroyed, will any memory stick around until the requiring script is also destroyed? If such a memory leak does happen, will it slow down the game or waste extra memory space?
If I could get some explanations to those questions, I would really appreciate it.