Plugins should be able to unload their changes before a place is published

As a Roblox developer, it is currently too hard to ensure any instances created / changed by a plugin are properly cleaned up when a user closes studio because any changes made within plugin.Unloading are ignored because studio publishes the place file before plugin.Unloading is fired.


Example

I have a plugin that completely overwrites studio’s camera controls. To do this I must set the CameraType to Scriptable. Once the plugin is unloaded, the CameraType is set back to Fixed, however if unloaded due to the place file being closed, the change to reset the CameraType won’t publish with the place; even if studio prompts the player to save on close.

This is a problem (for this case especially) because if a player was to run the plugin in Place1, leave and disable the plugin in Place2, they’d rejoin Place1, and not understand why their camera isn’t working, assuming the plugin broke their place file and posting negative reviews.


Proposed Solutions

  • Plugin.Unloading could fire before a place gets published on close. Though this opens the door for plugins clearing the entire workspace when the place file is closed without the user knowing until they re-open the place.
    Though I’m not really as concerned with this as it’s technically always been a possibility with a plugin setting all instances to non-archivable.

  • StudioService.PrePublish / Plugin.BeforeClose
    Such an API could prevent the problem with the above solution by using the plugin permission system so the user could determine which plugins are allowed to make changes before a place is published.

    I’m personally am more fond of a solution in the realm of StudioService.PrePublish as it covers certain edge-cases either of the other solutions don’t, such as a user publishing their place (while still editing), and then studio crashing before they get a chance to manually close.


Conclusion

If Roblox is able to address this issue, it would improve both my development experience, and the experience of the consumers who bought my plugins by ensuring that the plugin is properly cleaned up before the place file is published, and reducing the likelihood of negative reviews from users who assume the plugin broke their place.

8 Likes