Will Destroying a Folder delete all its contents?

Hello, I’m just wondering if using :Destroy() on a Folder in workspace will also delete all of its contents? I am trying to avoid memory leak so I want to make sure that whatever is in the folder isn’t still lingering around somewhere in memory after the command.

1 Like

Yes, everything that is a descendant of the object to be destroyed will also be destroyed.

Deleting any instance will delete all of its descendants.

Wow, that was quick. Thanks for the help!

2 Likes

Yes, but any reference to those instances inside a running script will still remain.

could you tell me how to stop that from happening thats the problem I am currently facing and have no idea how to fix

Just set the variables to nil.

That’s what maid objects are used for (not part of Roblox’s API, there are plenty of 3rd party libraries for this). Either you do it yourself by connecting a function to the Destroying event, or you use a Maid class which will usually have some kind of a trigger that runs a function of your choice.