saveinstance
Serializes one or more instances to the game's binary model or place format.
Syntax
saveinstance(root: Instance | {Instance}, options: SaveInstanceOptions?) -> ()
SaveInstanceOptions.new() -> SaveInstanceOptionsParameters
| Parameter | Type | Description |
|---|---|---|
root | Instance | {Instance} | An instance hierarchy, the DataModel, or an array of instances |
options | SaveInstanceOptions? | Optional serialization settings |
options must be a SaveInstanceOptions value created with SaveInstanceOptions.new(). Plain tables are not accepted.
Behavior
- Instances and arrays are saved as binary model files. Passing
gamesaves a binary place file. - If
FilePathhas no extension, Volt appends.rbxmfor a model or.rbxlfor a place. An existing extension is not validated or replaced. - If
FilePathis empty and clipboard output is disabled, Volt generates a filename.
SaveInstanceOptions
| Property | Type | Default | Description |
|---|---|---|---|
FilePath | string | "" | Workspace-relative output path |
IgnoreArchivable | boolean | false | Serialize instances regardless of Archivable |
SavePlayerCharacters | boolean | false | Include player characters in place output |
SavePlayers | boolean | false | Include Player instances and their non-creatable descendants |
DisableCompression | boolean | false | Disable binary compression |
DecompileScripts | boolean | true | Store decompiled source for scripts when possible |
SaveNonCreatable | boolean | false | Represent non-creatable instances as folders |
SaveNilInstances | boolean | false | Include cached nil-parented instances in place output |
CopyToClipboard | boolean | false | Copy binary output to the Studio clipboard |
IgnoreList | {Instance} | {} | Instances to exclude from the save |
DecompilerOptions | DecompilerOptions | New default options | Options used when DecompileScripts is enabled |
Assign a complete table to IgnoreList. Reading the property returns a read-only copy, so create or modify a separate table and assign it back when changing the list.
Example
local model = Instance.new("Model")
model.Name = "ExampleModel"
local part = Instance.new("Part")
part.Name = "ExamplePart"
part.Parent = model
local options = SaveInstanceOptions.new()
options.FilePath = "exports/example-model.rbxm"
options.IgnoreArchivable = false
options.DecompileScripts = true
saveinstance(model, options)
print(isfile("exports/example-model.rbxm")) -- true
model:Destroy()Saving Multiple Roots
local options = SaveInstanceOptions.new()
options.FilePath = "exports/selection.rbxm"
saveinstance({workspace.Terrain, workspace.CurrentCamera}, options)