Today I was making a quick little class converter plugin for personal use. Everything was fine, until I realized that it didn’t work with ChangeHistoryService because the original objects (that got destroyed in the conversion process) were not restored when undoing (even though I had used ChangeHistoryService:SetWaypoint() correctly).
That’s a real pain. And it explains why I had spent a long time thinking ChangeHistoryService was a pointless feature due to it being so unreliable in so many of the plugins I have used.
In my opinion this is a critical feature missing from ChangeHistoryService. Literally THE worst-case scenario that ChangeHistoryService should have been designed to prevent has been ignored (i.e. accidentally and permanently losing work when using a plugin).
Please give us a way to add deleted objects to waypoints.
Probably the reason you currently can’t do it with :Destroy()ed instances is because the goal of it is to disconnect all references and garbage collect it (free up the memory used by the instance). Clearing up the memory reference includes being able to undo destroying the instance. This could be implemented but may cause memory leaks.
You may be able to get around this for your plugin by using :Remove() instead of :Destroy(), but I have never tested if it works with the ChangeHistoryService.
Just came across a real need for this today. The somewhat new recording-based undo system doesn’t mitigate this either and falls for the same pitfall. As of now, I am forced to either intentionally allow possible memory leaks by simply setting the parent property to nil or magically determine all the references that the engine has for the object (which is impossible) and remove each one individually.