Help with using a ModuleScript to insert scripts into models

Okay since i finally found out how to let MainModule work i have a problem with inserting 1 script in every model that is in a folder here are a few pictures (because im bad in explaining)

pic:
https://gyazo.com/9da121b06d4d5af1287f1917b20cdb66

this red circle you see there is where the magic should happen (like to place the script in the right place )
but it does not work

this is how it should look like when the mainmodule works:

https://gyazo.com/30b3acf2e2f0dfa1ddfb150a1f7767fe

And you have to be able to dublicate M1 to M8 that’s why I did getchildren

Well I don’t understand your issue yet, please further elaborate.

You can not set an Instances’ Parent property to a table of Instances.
For example where in the module you do :

script.MLSelling.Parent = game.Workspace.PLights.M1:GetChildren()

GetChildren() returns an array of all children of a specified instance, sorted by the order in which their Parent property was set for example even if an instance has one child, you cannot do :

folder = workspace.Folder
print(folder:GetChildren().Name) --Incorrect

what you can, however do is

Something.Parent = -- one specific something else, not a table

-- you can also do this (a generic loop)

 for _, part in ipairs(folder:GetChildren()) do
        part.Parent = -- some other new instance
 end

Also one more thing I noticed about your code is that you are constantly setting
MLSelling 's Parent to multiple instances in a short time, that is without any waits or delay, so it’ll happen too fast and you’ll only notice it’s parent to be the instance you attempted to Parent last, that is PLights.M8 (remember not a table).

Also your module is a script, if you want a module then run it in a Module Script

  • this is how i setted it up
    im using ‘require()’

to let it work (i know i have to make it public to let it work but like i said that is not the issue i have)

here you see another thing i want that all 8 are working and that i can duplicate them

https://gyazo.com/f045898e8c176e4f186bf2316c8d5f96

Use script.Parent instead of using script.MLShelling.Parent

type

script.Parent.MLShelling = game.Workspace