messagebox
Displays a Windows message box and returns the user's response.
function messagebox(text: string, caption: string, flags: number): numberSynopsis
How it works
Calls the Win32
Combine with bitwise OR:
MessageBoxA API directly:
int result = MessageBoxA(
robloxHWND, // parent window handle
text, // body text (LPCSTR)
caption, // title bar text (LPCSTR)
flags // MB_* bitmask
);
return result; // IDOK=1, IDCANCEL=2, IDYES=6, IDNO=7, ...
The flags parameter is a bitmask combining button and icon constants:
| Flag | Value | Effect |
|---|---|---|
MB_OK | 0x00 | OK button only |
MB_OKCANCEL | 0x01 | OK + Cancel |
MB_YESNO | 0x04 | Yes + No |
MB_ICONWARNING | 0x30 | Warning triangle icon |
MB_ICONERROR | 0x10 | Red X icon |
MB_YESNO + MB_ICONWARNING = 0x34.Blocking behavior
MessageBoxA creates a modalModal dialogA window that blocks interaction with its parent window until dismissed. MessageBoxA() creates a modal dialog — the Luau thread is suspended until the user clicks a button. dialog and enters its own Win32 message loop. The Luau thread is blocked until the user clicks a button. Roblox continues rendering (the dialog is a separate window), but your script execution is paused. Use sparingly — it interrupts gameplay and can trigger AFK detection.Usage
Confirm dialog
local MB_OKCANCEL = 0x1
local IDOK = 1
local result = messagebox("Continue?", "Confirm", MB_OKCANCEL)
if result == IDOK then
print("User clicked OK")
endParameters
text string Body text of the dialog.
caption string Title bar text.
flags number Win32 MB_ flag combination (buttons + icon).
Returns
number Win32 IDBUTTON constant of the clicked button.
Yields
This function yields until the dialog is closed. Do not call it inside critical game loops.