I want to basically get 2 folders, and swap their contents around at the same time. Reason for this is I have a function that listens for when ChildAdded/ChildRemoved happens on these folders, and it can cause problems, because all the stuff from ‘FolderA’ goes into ‘FolderB’ and B still has its items, until a frame (or idk how long) before its items get moved over.
So here, all the items from ‘OldParentLocation’ get put into ‘NewFolderLocation’ while the contents of ‘NewFolderLocation’ is still there. So for a split second, ‘NewFolderLocation’ has both ‘OldParentLocation’ contents and its original contents
-- Get the stuff from the old parent and new parent
local OldParentData = {}
local NewParentData = {}
for _, v in pairs(OldParentLocation:GetChildren()) do
table.insert(OldParentData, v)
end
for _, v in pairs(NewParentLocation:GetChildren()) do
table.insert(NewParentData, v)
end
-- Parent old to new and vice versa
for _, v in pairs(OldParentData) do
v.Parent = NewParentLocation
end
for _, v in pairs(NewParentData) do
v.Parent = OldParentLocation
end
For anyone curious as to what this is, it’s basically for an inventory system where you can drag and drop items around your inv, so when they drag an item I need to swap the items data around so the data folders correspond to what the UI is showing