As a Roblox developer, it is currently impossible to cleanly check if an in-game instance was destroyed.
For context, this is different than simply having the Parent property set to nil
. An instance that is explicitly destroyed is special because certain aspects of the object become locked down. Currently, the only way to absolutely check if a part is destroyed is by trying to access one of these locked-down properties in a pcall
and see what the error is. This is not sufficient.
Example use-case: I want to create a module that acts as a wrapper around an in-game model. The module needs to know when to clean itself up, which should naturally occur when the model is destroyed. However, there’s no way to actually do this. The module could just listen for the Parent to be set to nil
, but that’s no guarantee that the model was actually destroyed! Perhaps the developer simply set the Parent to nil
temporarily and will add it back.
Addressing this issue would allow developers to properly check if an object is destroyed, thus allowing developers to create object wrappers.
A possible API addition would be a read-only boolean field on all instances called IsDestroyed
.