Синтаксис
saveinstance(rootOrOptions?: Instance | SaveInstanceOptions, options?: SaveInstanceOptions): stringАлиасы
SaveInstancesave_instanceАргументы
| Имя | Тип | Описание |
|---|---|---|
rootOrOptions? | Instance | SaveInstanceOptions | Optional root Instance to save, or the options table when no root is passed separately. |
options? | SaveInstanceOptions | Optional save options table. Used as argument 2 when argument 1 is an Instance. |
Возвраты
| Имя | Тип | Описание |
|---|---|---|
path | string | Filesystem path string of the saved .rbxlx, .rbxl, .rbxmx, or .rbxm file. |
Описание
Serializes the DataModel or a selected Instance to a Roblox XML place or model file and returns the saved path string. The root can be passed as the first argument, supplied as options.Object, or omitted to use game. FilePath, Path, or FileName can select the output name. The function may yield while loading the API dump before saving.
Вызывай с 2 параметрами: rootOrOptions, options. Таблица аргументов показывает обязательные значения и настройки поведения.
Возвращает path (string). Используй таблицу возвращаемых значений, чтобы отличать успех, nil и обрабатываемые ошибки.
Пример
Save a selected model to a Roblox XML model file and read the path returned by saveinstance.
local model = Instance.new("Model")
model.Name = "SavedModel"
local outputPath = saveinstance(model, {
FileName = "SavedModel.rbxmx",
Decompile = false,
NullifyScripts = true,
})
print(outputPath)
model:Destroy()Типы
SaveInstanceOptions
Options table read by saveinstance.
Object? Instance Root Instance used when no root Instance is passed as argument 1.FilePath? string Output name or path string. Path separators and colons are replaced before saving.Path? string Alternative output name field. It is read after FilePath.FileName? string Alternative output name field. It is read after Path.NullifyScripts? boolean Writes empty Source values for script classes when no source is emitted.Decompile? boolean Controls whether script bytecode is decompiled when source is not supplied and scripts are not nullified.DecompileScripts? boolean Alternative field for Decompile. It is read after Decompile.noscripts? boolean When true, disables script decompilation. When false, enables it.scriptcache? boolean Controls reuse of decompiled source by bytecode hash during one save operation.EmbedBytecode? boolean Writes captured bytecode for script classes when bytecode is available.SaveBytecode? boolean Alternative field for EmbedBytecode. It is read after EmbedBytecode.IgnoreDefaultProperties? boolean Skips properties whose serialized value matches the default value when default comparison is available.IgnoreSpecialProperties? boolean Controls whether special property reads are skipped.SourceCache? {[Instance]: string} Optional table mapping script Instances to source strings.IgnoreList? {string} Class names to skip during serialization. Built-in ignored class names are also applied.IgnoreProperties? {string} | {[string]: boolean} Property names to skip during serialization.IsModel? boolean Overrides whether the output is treated as a model file or place file for default name and extension handling.