Part.Destroying not firing

this is a snippet of a much larger code.
narrowed the issue down to the following.

the code:

local part = Instance.new("Folder")
part.Parent = workspace

part.Destroying:Connect(function()
	print("Destroyed")
end)

then I test the game, switch to the server, destroy the Folder and I expect it to print Destroyed. but nothing is printed.

Not exactly sure why that happens, but you can use AncestryChanged instead of Destroying and it will work.

you didn’t add destroy method lol

The Destroyed event only fires when the Destroy() function is called on said instance.

If you want to detect the instance being removed without using that method, you can use this:

part:GetPropertyChangedSignal('Parent'):Connect(function()
	if not part.Parent then
		print("Destroyed")
	end
end)

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.