I just need to clarify whether module scripts act as a global script that functions can pass requests to, to be calculated, or if they act as scripts that can be 'downloaded' into other scripts to be run locally (essentially embedding).
I was under the impression that they operated similarly to remote events, however some recent code ive been running has been producing duplicate results, leading me to believe that they instead operate internally on the scripts that pull them, and overwrite variables when they are pushed back on completion.
Because of this, im currently using a rand func to assign time to before the functions are being run, so that their is no concurrent function being deployed that would either duplicate or overwrite the data of another in operation. Its not a very good fix, but for the moment it works, but I feel it would fail under a stresstest of multiple players.
If the code is copied out to each script pulling it, and it is infact a central process that is just being passed variables via request function, then il probably move to build a queue system to process each request individually, since theyre small and non time consuming. However if they are as theorised above, then im not sure what to do about my issue that would prevent these issues in an ironclad manor.
function module.Population(oldRegion, newRegion, Player)
local x = math.random(10)/10
wait(x + timeOffset)
timeOffset = x
if buildlock == true then
wait(1)
module.Population(oldRegion, newRegion, Player)
else
--Actual code and other functions that I want to trigger
As you can see, im using a boolean statement to control majority of the requests, and an offset variable to manage any events triggered simultaneously. But for all I know, theyre both redundant pending on how these modulescripts actually operated.
Appreciate any solid explanation. Thanks

3 comments
Is it possible to build a single script that handles the collisions for a subset of parts that are cloned into the workspace, rather than building a linked script and embedding it into each part that then runs the collision checks themselves?
That's totally possible. You first need to get a reference to each part (by iterating over the table returned by Instance.GetChildren, for example), then simply connect the Touched event of each part to a function that handles the collision input.
So I would be looking at creating a table that stores the adresses for each required part to a table, and iterating over it with a do while loop on a global script to check for collisions?