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.

Syntax
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.

Function parameters
ParameterTypeDescription
callbackFunctionFunction 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

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()