OnInstanceLeave||doc136825

September 20, 2022

Format

local event = BasePart:GetEvent("OnInstanceLeave")

Describe

Triggered when an instance leaves the scene.

Callback function parameters

Type name introduce
Map map Current scene
Instance ins Leave the instance of the scene

Code example

Register the instance on the server to leave the static scene "map001" event

local map = World:GetStaticMap("map001")

local part = Instance.new("Part", map.Root)

local event = part1:GetEvent("OnInstanceLeave")
event:Bind(function(map, ins)
    print("OnInstanceLeave!", map, ins)
end)

part:Destroy()