Explorer doesn't fire Destroying signal when deleting an instance while in play test

If you delete an instance while in a play test it doesn’t fire Instance:Destroying() script signal.

I’m trying to make my own custom explorer as it’s a useful debugging tool, and I tried fixing instance displays not deleting when I deleted them in the explorer only find out that the studio explorer doesn’t fire destroying signal while in play test for whatever reason

I’m guessing this is intentional because when you delete a part and undo the deletion, the part from the undone deletion is the same part as the one that was deleted. If the part was destroyed, there’d be no way to recover it from that state.

Try this in your command line:
a=workspace.Part
Delete the part, undo
=a==workspace.Part → true

If you destroy the part manually and try to undo via ChangeHistoryService, it will be impossible to recover the part:

s=game.ChangeHistoryService:TryBeginRecording('uep', 'yepyepyep') 
workspace.Part:Destroy()
game.ChangeHistoryService:FinishRecording(s,Enum.FinishRecordingOperation.Commit)

Then press undo, you will get this warning because the part is destroyed:
image

I suppose I should of clarified it more, I can see as to why you wouldn’t want it to fire the destroying signal because of undo however, the problem is that it’s not firing it while in testing sessions, which for my particular case was quite annoying.

its intentional bc it doesn’t call :Destroy() on the instance it only parents it to nil (just like :Remove() does, so detect it by checking GetPropertyChangedSignal(“Parent”) and if it’s in nil)

As described before, this is intended behavior to allow you to undo deletions.

Maybe it could be possible to make it actually destroy the object when RunService:IsRunning(), since you can’t undo deletions during playtests?

It always trips me up that those deletions don’t fire .Destroyed and I hate to use the command bar for testing.

If you don’t actually need to know if something is destroyed, you can opt to do:

thing.AncestryChanged:Connect(function()
    if thing:IsDescendantOf(game) then
        return
    end

    -- code here
end)

…but we won’t be changing what Explorer does here.