Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Detect if part is destroyed?

Asked by 5 years ago

Hello, I want to detect when a part has been deleted.

I've got no idea how to do this.

1 answer

Log in to vote
0
Answered by
NotedAPI 810 Moderation Voter
5 years ago
Edited 5 years ago

Hello, isaacjh100!

To detect when a part is removed/deleted you can use ChildRemoved or DescendantRemoving. The following code I'm about to show is using the ChildRemoved event.

workspace.ChildRemoved:Connect(function(child)
    print(child)
end)

If you want it to run a something when a certain part is deleted you can do this:

workspace.ChildRemoved:Connect(function(child)
    if child.Name == "Part" then
        print("hey")
    end
end)

You can edit this code to your liking.

0
Thank you :) isaacjh100 41 — 5y
Ad

Answer this question