savefiledialog Asynchronous

Give the user a save picker and write the supplied bytes at their chosen location. Prepare the complete export before opening the dialog.

Syntax
Luau
savefiledialog(contents: string, options: FileDialogOptions?) -> Document?

Parameters

Function parameters
ParameterTypeDescription
contentsstringString to save, including binary bytes if needed.
optionsFileDialogOptions?Optional FileDialogOptions table; use its named fields to guide the system picker.

Argument fields

FileDialogOptions fields
Luau
FileDialogOptions = {
  defaultPath: string?, title: string?, extensionFilter: {string}?,
  suggestedName: string?, defaultExtension: string?
}
FieldDescription
defaultPathInitial picker location. The Android picker uses this only when it is a content:// URI.
titleOptional chooser title for open dialogs. It is not used as the save filename.
extensionFilterArray of extensions, such as {"txt", "json"}. Known extensions are converted to MIME filters; unknown-only filters allow all types. Folder dialogs do not use this filter.
suggestedNameSuggested filename for savefiledialog. Defaults to untitled when omitted or empty.
defaultExtensionExtension appended to the suggested save filename when it does not already have that extension. Leading dots are removed.

Returns

Document?

A Document for the saved file, or nil if the picker is cancelled.

Usage notes

A Document is a handle to the user-selected location, not a workspace path. Call methods with a colon and keep the handle for later operations.

suggestedName can propose a filename; the user still chooses the final destination.

Example

Example
Luau
local data = json.encode({ exportedAt = os.time() })
local document = savefiledialog(data, { suggestedName = "example-export.json" })
if document then print("Saved:", document:GetName()) end
Kawaii documentation