GetEvent||doc136418

September 20, 2022

Format

Instance:GetEvent(eventName)

Describe

Get instance events.

parameter

Variable name Type Describe
eventName string Event name

Return value

Type Describe
BindableEvent Bindable events

Code example

Get the bindable event that the instance is destroyed, bind the function, and print the information each time it is destroyed.

local part = Instance.new("Part")
local destroyEvent = part:GetEvent("OnDestroy")

destroyEvent:Bind(function()
    print("on destroy")
end)

part:Destroy()