Smapshot
Smapshot allows for dynamic saving and loading of maps.
Types
TerrainConfig
interface TerrainConfig {slice: (BasePart | Region3int16)?--
Region of terrain to save. If a BasePart is provided it is converted to a Region3int16. When nil, all terrain is saved.
}LightingConfig
interface LightingConfig {whitelist: {string}?--
Names of Lighting children (effects, atmospheres, skies) to include. Mutually exclusive with blacklist.
blacklist: {string}?--
Names of Lighting children to exclude.
}InstanceConfig
interface InstanceConfig {saveParents: boolean?--
When true, each instance's original parent path is recorded so it can be restored on load. Defaults to false.
}WorkspaceConfig
interface WorkspaceConfig {whitelist: {string}?--
Names of Workspace children to include. Terrain and CurrentCamera are always skipped here. Mutually exclusive with blacklist.
blacklist: {string}?--
Names of Workspace children to exclude.
saveCameraCFrame: boolean?--
When true, the current Camera.CFrame is captured and restored on load.
}MusicConfig
interface MusicConfig {whitelist: {string}?--
Names of SoundService children to include. Mutually exclusive with blacklist.
blacklist: {string}?--
Names of SoundService children to exclude.
}MaterialConfig
interface MaterialConfig {whitelist: {string}?--
Names of MaterialService children to include. Mutually exclusive with blacklist.
blacklist: {string}?--
Names of MaterialService children to exclude.
materialFilter: {Enum.Material}?--
If provided, only MaterialVariants whose BaseMaterial is in this list are captured.
}SimpleLoadOverwrite
interface SimpleLoadOverwrite {keepDirty: boolean?--
When true, existing state is preserved instead of being cleared before this section is applied. Overrides globalKeepDirty for this section.
consume: boolean?--
When true, the section's children are reparented into the target service instead of cloned, and the section is tagged so it is skipped on subsequent loads. Overrides globalConsume for this section.
ignoreOnLoad: boolean?--
When true, this section is skipped entirely on load.
}LoadOverwrite
interface LoadOverwrite {keepDirty: boolean?--
When true, existing state is preserved instead of being cleared before this section is applied. Overrides globalKeepDirty for this section.
consume: boolean?--
When true, the section's children are reparented into the target service instead of cloned, and the section is tagged so it is skipped on subsequent loads. Overrides globalConsume for this section.
ignoreOnLoad: boolean?--
When true, this section is skipped entirely on load.
ignoreOnClear: {Instance}?--
Instances to leave in place when the target service is cleared (only applies when keepDirty is not set, since that is the only path that clears).
}LoadConfig
interface LoadConfig {globalConsume: boolean?--
Default consume applied to every section that does not set its own. See SimpleLoadOverwrite.
globalKeepDirty: boolean?--
Default keepDirty applied to every section that does not set its own.
globalIgnoreOnClear: {Instance}?--
Default ignoreOnClear applied to every clearing section (Lighting/Workspace/SoundService/MaterialService) that does not set its own. See LoadOverwrite.
}Functions
Snapshot
Types
interface SnapshotConfig {name: string?--
Name applied to the returned snapshot Folder.
saveDefaults: boolean?--
When true, properties that match Roblox defaults are still serialized.
lightingConfig: LightingConfig?--
Lighting properties and children to capture. Omit to skip lighting.
workspaceConfig: WorkspaceConfig?--
Workspace properties and children to capture. Omit to skip workspace.
materialConfig: MaterialConfig?--
MaterialService properties and material variants to capture. Omit to skip materials.
}Creates a snapshot of any combination of terrain, lighting, workspace, music, materials, and arbitrary instances based on the supplied SnapshotConfig. Any config field that is omitted is skipped.
The returned Folder can later be passed to Smapshot.Load to restore the captured state.
If config.saveLocation is set, the folder is parented there with a unique name.
local snapshot = Smapshot.Snapshot({
name = "Arena",
saveLocation = game:GetService("ReplicatedStorage"),
terrainConfig = { slice = workspace.ArenaBounds },
lightingConfig = { blacklist = { "Sky" } },
workspaceConfig = { saveCameraCFrame = true },
instanceConfig = { instances = { game:GetService("ReplicatedStorage").Arena.Weapons } },
})
IsCompatible
Smapshot.IsCompatible() → boolean--
The result of the validation.
Checks if the input has been made by Smapshot.Snapshot.
Smapshot.IsCompatible(Smapshot.Snapshot({})) -- true
Smapshot.IsCompatible(Instance.new("Folder")) -- false
ReadVersion
Smapshot.ReadVersion() → string?--
The stored version string, or nil if there is none.
Reads the Smapshot version string that was stamped onto a snapshot at creation time.
Returns nil if the value is missing (e.g. the instance was not produced by Smapshot.Snapshot).
Smapshot.ReadVersion(Smapshot.Snapshot({})) -- "0.2.0"
Smapshot.ReadVersion(Instance.new("Folder")) -- nil
GetAssetAsync
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsSmapshot.GetAssetAsync(snapshotId: number--
Asset id of an uploaded snapshot.
) → Folder--
The loaded snapshot.
Gets a snapshot from a Roblox asset id.
The asset is fetched via AssetService:LoadAssetAsync and cached.
Use Smapshot.Load to load the map snapshot.
Smapshot.GetAssetAsync(1234567890)
Load
Smapshot.Load(config: LoadConfig?--
Optional LoadConfig describing how each section is applied: clear vs keep (keepDirty), clone vs consume (consume), or skip (ignoreOnLoad). Per-section values fall back to globalKeepDirty / globalConsume. Omit to clear and clone every section.
) → Folder--
The loaded snapshot.
Loads a snapshot folder previously produced by Smapshot.Snapshot.
Use Smapshot.LoadAssetAsync when loading from a Roblox asset id instead.
Smapshot.Load(snapshot)
-- Reset the workspace but consume everything else (cheaper, one-shot):
Smapshot.Load(snapshot, {
globalConsume = true,
workspace = { consume = false },
})
LoadAssetAsync
This is a yielding function. When called, it will pause the Lua thread that called the function until a result is ready to be returned, without interrupting other scripts. YieldsSmapshot.LoadAssetAsync(snapshotId: number,--
Asset id of an uploaded snapshot.
config: LoadConfig?--
Optional LoadConfig describing how each section is applied: clear vs keep (keepDirty), clone vs consume (consume), or skip (ignoreOnLoad). Per-section values fall back to globalKeepDirty / globalConsume. Omit to clear and clone every section.
) → Folder--
The loaded snapshot.
Loads a snapshot from a Roblox asset id.
The asset is fetched via AssetService:LoadAssetAsync and cached for subsequent loads.
Use Smapshot.Load when loading from an in-memory snapshot Folder instead.
Smapshot.LoadAssetAsync(1234567890)