Force require() to require multiple times?

Hello everyone. Today I found out that require only requires the module once and then returns the same value. I have a module that breaks with this and because of this; I need require to require multiple times.

I cannot Clone the module since I need the ancestors and descendants to remain the same, and I also need it to be able to be running any time. This makes it impossible for me to just clone the module and destroy it since by destroying it I delete its Children.

Is there a solution to this? Using a :Init function would also not work since I need the children and descendants to be always there. I can also not just clone the module because if I do so I will end up with multiple instances in the same place and breaking things.

Can someone help? Thanks! Furthermore, why isn’t it a feature to disable this, like a “require” that doesn’t have cache?

Could you explain your use case a bit more? There is no scenario I can think of where this will break your script.

1 Like

Wait a second, you just made me realize something. It isn’t about breaking or not, not even related to the post’s original question.

I thought about it and my modules return a function and so theoretically speaking the function should create a new table every time it is called (the table is created locally) and so because of that it doesn’t matter if it is the same function or not. So the problem is that the module is not being called twice, but it isn’t because of require() but rather my own stupidity.

Honestly, thanks for making me realize that! :slight_smile: