Requiring a Parented Module

I want to require a ModuleScript that is parented to my current script, after I require I change the ModuleScripts Parent, and the Script’s Parent. However the variable I set that is equal to the required module gets overridden somehow.

I commented out my code so its barebones however it still doesn’t work.
modulemystery.rbxl (16.6 KB)

After testing your place it appears to be working, however, you are printing the whole table (https://gyazo.com/8e74ebcc336f29d1f09af5eff8041967) which results in this output (https://gyazo.com/03f216671fd2f2ab9ce68da0dcf9def1) so that may be the cause why you believe it isn’t working correctly (however it is unless I misunderstood you).

image
its getting overriden, thats the issue. How come its printing 2 things

You can easily just require the module from another place from the script inside workspace, as how you’re setting the variable setting then requiring it is probably messing with the requiring of the module. Try adding the module to ReplicatedStorage or ServerScriptService, then require it from a variable inside the script.

I agree with @desinied, as you are then later going to require it from ReplicatedStorage anyway (commented but I suppose you did that for testing) https://gyazo.com/479ddf66dc6b5aec55eef0ac31bfe93e you should just keep the script there from the start to avoid all this moving around you currently do.

Its meant to be a freemodel for people who aren’t script savvy, so whenever they place the model in the game the objects go into their correct place, so it’s why I’m doing it this way. So this isn’t really a solution for it.

I see your point. If you wish to then you can just use the following little kit I made to parent everything correctly. Just place the scripts in the folders and create new folders if you need to move something to another child of “game”.

Automatic Installation Kit.rbxm (852 Bytes)

1 Like

It’s printing two things because the script runs again when you re-parent it.

1 Like