How do I make a clean up script?

In my game, there’s bombs that you can spawn. However, when the map changes, they get stuck in the environment, so I want to try and find a way to clear them up before a map change. Any ideas?

You could make the bombs spawn in a specific folder in the workspace and then when the round ends you can simply do Instance:ClearAllChildren() to the folder which will clean up anything inside of it.

Create a folder named Temp in workspace.
Parent those bombs in temp folder.

Now when the map changes do



for i,v in pairs(workspace.Temp:GetChildren()) do

hi oof; If you put the bombs in a folder in workspace, you can clear all of the folder’s children by FOLDER:ClearAllChildren()

already tried it, worked well. thanks