How to i get children after i remove them

Hello

i made a script which removes all the children in a certain folder however, i was unable to get the children back into the folder

script.Parent.MouseEnter:Connect(function()
	script.Parent.Parent.Parent.FrontGames:GetChildren()
	script.Parent.Parent.Parent.FrontGames:ClearAllChildren()

end)

How to i return the children to the folder after i remove them?

Try reversing lines 2 and 3

(Ignore this, this is for extra chrarcaters)

Lemme know if this works.

For example,:

script.Parent.MouseEnter:Connect(function()
script.Parent.Parent.Parent.FrontGames:ClearAllChildren()
script.Parent.Parent.Parent.FrontGames:GetChildren()
end)

Right now you are getting the children but then are clearing them which means you are just removing them.

Here I would define the children removed from the folder, so that way you have a table to return them back. I think this is where you got stuck.

Edit:

I also wrote too fast lol. You are deleting the children with ClearAllChildren(), meaning you can’t get them back. So make sure to change their parent using a for loop, don’t delete the instances or delete the instances and create a clone that can be stored in ServerStorage.

I’m not sure how this returns the children? You can’t Get an instance or instances that don’t exist. ClearAllChildren() is simply a way of destroying (Destroy()) multiple instances

1 Like

Whoops I forgot. @LowIQLarry you should probaly make a table with the children then return the children using the table.

If your removing the children then they won’t be existent any more, what I would suggest is to clone all of the children in the file before removing them. Then moving these clones into the file you want.