So I have multiple folders with the same name. They all contain models with the same name. How would I ungroup all of the models in all of these folders, and then delete the folder and just make everything belong to the workspace?
script in the screenshot does not work, I put it in the command bar and it did nothing.
local Bush = game.Workspace:GetChildren("Bush")
for _,child in ipairs(Bush) do
if child.Name == "Bush" and child:IsA('Model') then
child.Parent = workspace
_:Destroy()
end
end)
I don’t know of a way to ungroup models via script
for i, v in pairs(game.Workspace:GetChildren()) do
if v.Name == “Bush” then
for k, j in pairs(v:GetChildren()) do
for a, b in pairs(j:GetChildren()) do
b.Parent = game.Workspace
end
end
end
end
Now i know this is probably not the easiest way, and is kind of confusing, but i think that will go through each folder and model and set the part’s parent to the workspace.
The problem is with the quotes. Switch the quotes @Carl_Weezer13 used with normal quotes from your keyboard. I’m surprised you didn’t catch that detail but I guess things can be a little tricky.
for i, v in pairs(game.Workspace:GetChildren()) do
if v.Name == 'Bush' then
for k, j in pairs(v:GetChildren()) do
for a, b in pairs(j:GetChildren()) do
b.Parent = game.Workspace
end
end
end
end
for _, Folder in pairs(workspace:GetChildren()) do
if Folder:IsA("Folder") and Folder.Name == "Bush" then
for _, Model in pairs(Folder:GetChildren()) do
for _, Child in pairs(Model:GetChildren()) do
Child.Parent = workspace
end
end
Folder:Destroy()
end
end
Thank you!!! I’m putting all of the flower blocks into 1 folder. Inside all of these folders there are also grass blocks. I’m going to put all of the grass blocks into another folder. I then have 2 scripts that are going to go inside of these 2 folders and put a bush where all of the grass blocks are placed, and a type of flower or mushroom where all of the flower blocks are placed.