Skip to main content

OnEvent

Connects to a named Roblox instance event.

TypeSinceScoped
Connection0.0.1Yes

Constructor​

OnEvent(EventName : string) -> Binding

-- Embedded:
[OnEvent(EventName)] = (...any) -> ()

-- Standalone:
OnEvent(EventName)(Instance, Callback) -> RBXScriptConnection

Methods (Binding)​

Destroy()​

Disconnects all active connections created by this binding.

Usage​

New("ImageButton", {
[OnEvent "Activated"] = function()
print("clicked")
end,

[OnEvent "MouseEnter"] = function()
print("enter")
end,
})

Equivalent to Instance[EventName]:Connect(Callback). Rebinding the same event on the same instance replaces the previous connection. Call Destroy() on the binding to disconnect everything it owns.