I’m making a Studio plugin where I press a textbutton to destroy an object and use the change history service to set a waypoint, but when I undo this action the objects don’t get re-added to the workspace
The code looks a bit like this (I’ve simplified it to make it more readable):
ChangeHistoryService:SetWaypoint("Remove object")
obj:Destroy()
ChangeHistoryService:SetWaypoint("Remove object")
I’ve also tried using different names for the start and end waypoints, but neither of those make a difference.
The object I’m destroying is a model that contains many nested parts, models and values inside it. When I press undo I get some warning text in the output saying “The parent property of X is locked, current parent:NULL, new parent Y” for what looks like every descendant of that model.
I’m also using the change history service for a few other actions and not seeing any issues, including when I add the very object I’m deleting via another button. If I undo the add action it will remove the object as expected, and then if I redo that undo it will add it back again. So I’m not really sure what’s different here, especially since if I manually delete the object in explorer the undo works fine.
Does anyone know what I’m doing wrong here? Is there an alternative way to destroy the object that I’m missing?
Thanks in advance for your help!