Document: Write Synchronous
Replace the entire contents of a selected file. This is appropriate when the user has approved updating an export in place.
Luau
Document:Write(contents: string) -> ()Parameters
Call this method with a Document receiver. The colon supplies self implicitly; a dot call must pass the receiver explicitly.
| Parameter | Type | Description |
|---|---|---|
contents | string | Replacement text or binary bytes. |
Returns
()No values.
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.
Writing to a folder raises. Use Append when previous content must remain.
Example
Luau
local document = savefiledialog("Draft", { suggestedName = "note.txt" })
if document then
document:Write("Final note")
print(document:Read())
end