Calling :Destroy() from a plugin when unloading doesn't work when closing studio

  1. What do you want to achieve?: I have a plugin that essentially creates a part inside workspace, and I would like to destroy this part when I close studio.

  2. What is the issue?: Closing studio in a place with team create will leave the part there for other people.

  3. What solutions have you tried so far?: I’ve implemented the unloading event to destroy it, which DOES work when disabling or updating said plugin, just not with closing studio or the place.
    I’ve also searched all over the devforum and documentation and can’t find anything.

I’m fairly sure every person on team create is in “Players” you loop over the players then you might be able to call the destroyed event and also check if there are any other players, if not then part destroy.

Not 100% if this is a solution I’ve never created a plug-in before.