My game needs to be a multiplace game, therefore I thought of using packages to keep scripts synced up between the places. However, it tends to mess up the hierarchy of all the scripts already calling the services!
How would I get around this, or act like the package folder does not exist?
yeah I was thinking of that, don’t know why but I felt it might cause some problems. Looks like the only solution though, so I’ll probably just do that for the time being.
what about a script that loops through the whole game and if something is named “Package” it would transport all the children inside it outside of the folder? or would that be too unoptimized?
for example:
for _,pack in pairs(game:GetDescendants()) do
if pack.Name == "Package" then
for _,v in pairs(pack:GetChildren()) do
v.Parent = v.Parent.Parent
end
end
end
Sure, you can try that.
Using game:GetDescendants() may be sometimes heavy, if you have like 1k objects in game.
If you’ll use this way, make sure every unpacked object you are trying to get is accessed using :WaitForChild("object").
If you want to access any unpacked object from your package, use WaitForChild.
Because the objects aren’t instantly moved from it you’ll need to wait for them.