MessageBox: OnChoice Synchronous
Set the function that receives the choice, replacing any Callback given in the options. Use it when the handler is only known after the box is created.
Luau
MessageBox:OnChoice(callback: Function) -> ()Parameters
Call this method with a MessageBox receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.
| Parameter | Type | Description |
|---|---|---|
callback | Function | Function called once with the choice string. |
Returns
()No values.
Usage notes
Set the callback before the choice is made; a choice made earlier is not delivered again.
Example
Luau
local box = MessageBox.new({Text = "Keep these settings?", Buttons = {"Keep", "Revert"}, Yield = false})
box:OnChoice(function(choice)
print("The user chose", choice)
end)
box:Show()