However, if I require the module more than once the pre-loaded module’s values passed get overwritten by the other caller’s objects.
This is how I’m testing with multipule modules:
2 objects.
However, the 1st object loads correctly however, when the 2nd object loads the 1st object’s plane, mainPart, mainSeat objects are replaced with the 2nd object’s ones.
Sorry if this thread sounds confusing. If you need more info I can provide you with it
Is this any specific use case for this over making a specific function in said module that would add a plane to a table within the module script?
I only mention this because the “typical” way of using module scripts, at least how I use them, would be to require it once where needed and use functions within, rather than requiring it twice as you are.
Just one more note, you can put a table inside of the local myModule = {} it would work like so
local myModule = {
planes = {},
}
Then you can make a function like this:
function myModule:addPlane(plane, mainPart, mainSeat)
local planeTable = {plane, mainPart, mainSeat}
table.insert(self.planes, planeTable)
end
This is just an example of you can go about adding it to your module script. Hopefully it gives you a little more insight on how to solve your problem. It’s also helpful to note that you should figure some way of identifying your planes so it is easier to remove them from the table as well, whether it’s returning the index of where it was added to the table, etc.
Note: I am on mobile and have not tested the above code.