ReferenceScripts

saveinstance

Saves the game, or part of it, to a file in your workspace folder that Roblox Studio can open.

Syntax

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

Parameters

ParameterTypeDescription
rootInstance or {Instance}?What to save: one Instance, an array of Instances, or nothing for the whole game.
optionsSaveInstanceOptions or table?How to save it. See the description.

Description

With no options, or with an object from SaveInstanceOptions.new(), the file is binary: .rbxl for the game and .rbxm for anything else. With an ordinary table of options it is XML: .rbxlx or .rbxmx. The call yields until the file is complete; the file appears only once it has been fully written.

The options are FilePath (the file name, with or without extension), DecompileScripts (put decompiled source in scripts; default true), IgnoreArchivable, SaveNilInstances, SavePlayers, SavePlayerCharacters, SaveNonCreatable, IgnoreDefaultProperties, DisableCompression, IgnoreList (an array of Instances to leave out with their descendants) and the decompiler settings from DecompilerOptions.

Example

saveinstance()

saveinstance(workspace.Map, { FilePath = "Map" })

local options = SaveInstanceOptions.new()
options.SaveNilInstances = true
options.IgnoreList = { game.Players }
saveinstance(game, options)

Notes

These are Game executor contracts. Check build requirements and session lifetimes before using them.