How do I check that a part was :Destroy()'ed?

Yes, it would. The cases where you actually need to check if something is destroyed specifically are niche.

1 Like

The GetInstanceRemovedSignal still fires if the part is parented to nil but not explicitly :Destroyed.

As for my usecase… well I can’t remember exactly why, to be honest. It’s been a year since I posted the OP, after all. But there are several threads out there (this and to some extent this) which show some reasons why one would want to check if something was destroyed.

EDIT: Meant to reply to @Kampfkarren

2 Likes

That’s strange, I don’t remember it working like that.

1 Like

Is there still a way to fix this problem? I am setting parent to nil and using AncestryChanged. It still says its destroyed.

Or you could use the fact that :Destroy() removes every children of an instance when called.
image
If CheckIfImInsidePart’s parent changes and you’re sure it wasn’t cuz of you you can assume Part is destroyed.

When a part is destroyed, the parent is set to nil.

if part.Parent == nil then
    print("Part is destroyed!")
end

You didn’t read the thread before posting that. OP couldn’t check just the parent because a nil parent doesn’t imply destruction. Instances can live in nil (memory) without being destroyed or garbage collected if your code keeps them alive.

See the upcoming event Instance.Destroying from Release 500:

4 Likes

Not true. A part programmatically parented to nil (Part.Parent = nil) isn’t necessarily :Destroy()'ed.

4 Likes

Thank you very much! This worked for my rainbowify function, It kept memoryleaking but thanks to this it finally stops. Absolute life saver.

Sorry Necro Post, but it looks like this post still gets views.

Here is the updated solution

1 Like

There’s a nice way to do this with Tags now that we have the .Destroying event

local CollectionService = game:GetService("CollectionService")

local DESTROYED_TAG: string = "Destroyed"

local part = Instance.new("Part")
part.Parent = workspace
part.Destroying:Once(function()
	CollectionService:AddTag(part, DESTROYED_TAG)
end)

print(CollectionService:HasTag(part, DESTROYED_TAG)) -- false

part:Destroy()

print(CollectionService:HasTag(part, DESTROYED_TAG)) -- true

Wouldn’t a simple

if not model.Parent return --[[ or continue or break whatever fits your use case]] end

do the trick though?