Hi, I once figured out a way to do this but can’t remember how. My brain’s tired. lol.
Ok, so I have 2 folders in the workspace. One of the folders contains (let’s say for example), 20 parts with different names. The second folder contains only some of the same named parts that the first folder has. Now, how do I create a 3rd folder, filled with only parts from the first folder, that are not contained in the second folder?
Thanks.
local newfolder = Instance.new("Folder", workspace)
newfolder.Name = "3RD Folder"
for _, child in pairs(workspace["1ST Folder"]:GetChildren()) do
if not workspace["2ND Folder"]: FindFirstChild(child.Name) then
child:Clone().Parent = newfolder
end
end
1 Like
local Folder1=workspace.Folder1:GetChildren() -- Get all parts in folder1
local Folder2_PartNames={}
local Folder3=Instance.new("Folder") Folder3.Name="Folder3" Folder3.Parent=workspace -- Create a new folder
for _,v in ipairs(workspace.Folder2:GetChildren())do table.insert(Folder2_PartNames, v.Name) end -- Add all part names of folder2 for searching
for _, instance in ipairs(Folder1) do
if not table.find(Folder2_PartNames, instance.Name) then instance.Parent=Folder3 end -- Search for matching names in folder 1 and folder 2, if no matching name then move it from folder1 to folder3
end
2 Likes
This will move those parts from first folder to the third folder.
1 Like