OnDestroy||doc136714

September 20, 2022

Format

local event = Instance:GetEvent("OnDestroy")

Describe

Triggered when the instance is about to be destroyed

Callback function parameters

Type name introduce
Instance instance Current instance

Code example

local map = World:GetStaticMap("map001")
local part = Instance.new("Part", map.Root)

local event = part:GetEvent("OnDestroy")
event:Bind(function(instance)
    print("destroy instance!", instance)
end)

part:Destroy()