Any instance put into the modelsExpectedToBeDestroyed table will fire the function. If the instance has a parent of nil, the object is considered to be destroyed, if not, the instance changed parents, which has another function if you wanted something to change if that were the case instead.
-- Script
local CollectionService = game:GetService("CollectionService")
local modelsExpectedToBeDestroyed = {workspace.Part} -- Instance(s) here will fire the function upon being destroyed, put into a table. (e.g. 'workspace.Part')
for index, instance in ipairs(modelsExpectedToBeDestroyed) do
CollectionService:AddTag(instance, "modelsExpectedToBeDestroyed")
end
for index, instance in pairs(modelsExpectedToBeDestroyed) do
local function isChildDeleted()
if instance.Parent == nil then -- Instance has been destroyed.
print(instance.Name .. " has been destroyed.")
else -- Instance has been moved to another parent.
print(instance.Name .. " has been moved to " .. instance.Parent.Name .. ".")
end
end
instance:GetPropertyChangedSignal("Parent"):Connect(isChildDeleted)
end
Let me know if this helps.