saveinstance

Serializes one or more instances to the game's binary model or place format.

Syntax

saveinstance(root: Instance | {Instance}, options: SaveInstanceOptions?) -> ()
SaveInstanceOptions.new() -> SaveInstanceOptions

Parameters

ParameterTypeDescription
rootInstance | {Instance}An instance hierarchy, the DataModel, or an array of instances
optionsSaveInstanceOptions?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 game saves a binary place file.
  • If FilePath has no extension, Volt appends .rbxm for a model or .rbxl for a place. An existing extension is not validated or replaced.
  • If FilePath is empty and clipboard output is disabled, Volt generates a filename.

SaveInstanceOptions

PropertyTypeDefaultDescription
FilePathstring""Workspace-relative output path
IgnoreArchivablebooleanfalseSerialize instances regardless of Archivable
SavePlayerCharactersbooleanfalseInclude player characters in place output
SavePlayersbooleanfalseInclude Player instances and their non-creatable descendants
DisableCompressionbooleanfalseDisable binary compression
DecompileScriptsbooleantrueStore decompiled source for scripts when possible
SaveNonCreatablebooleanfalseRepresent non-creatable instances as folders
SaveNilInstancesbooleanfalseInclude cached nil-parented instances in place output
CopyToClipboardbooleanfalseCopy binary output to the Studio clipboard
IgnoreList{Instance}{}Instances to exclude from the save
DecompilerOptionsDecompilerOptionsNew default optionsOptions 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)