Detect when a part who touch another part is removed

Hello! I have a problem and I don’t know how to solve it. Here is the problem.

There are two parts: Part0 and Part1.
I can detect when Part0 touch Part1 or when Part0 no longer touch the Part1 but Part1 can be destroyed and I don’t know how to detect if Part0 touch Part1 then Part1 is destroyed.

This is hard to explain. If you didn’t understood. Please say me where you didn’t understood.

Could you help me please?

local Part0 = --part0
local Part1 = --part1

Part1.Touched:Connect(function(part)
--sorry i dont know how to use indents
if part == Part0 then
Part1:Destroy()
end
end)

This should work. It connects a touched event for Part1 to a function and then when it fires then it checks if the part that touched it is Part0. If it is, then Part1 gets destroyed.

You didn’t understood my problem.
I would like an event like Part1.TouchEnded but who also work when Part1 is destroyed.

Could you be more clear abt it pls. R u trying to detect if part1 is destroyed?

I don’t understand. Do you want it so if Part1 stops touching Part0 you want it to be destroyed? Or do you want it to detect it when it gets destroyed? If you want to detect it when it gets destroyed I just recommend anchoring the part, setting transparency to 1 and CanCollide false so you can still detect it as otherwise it is impossible.

I want to when Part0 touch Part1 then Part1 gets destroyed Part0 receive an event and do a ramdom function (So in the answer, there must not are a function.).

local function randomFunc()
end

Part0.Touched:Connect(function(part)
    if part == Part1 then randomFunc() end
end)

Unless you use Part0 or Part1.Touched:Wait() you have to connect it to a function.