Instance2Lua Place Saver
Key RequiredUniversal

Instance2Lua Place Saver

Universal ScriptFoarteBineFoarteBine 476 views 318 executesUpdated Jul 1, 2026
Unrated
00
Lua Script•199 lines (8479 chars)
local Target = game:GetService("Workspace") --SELECT YOUR TARGET
local Output = "-- Generated automatically\nlocal create = Instance.new\nlocal refs = {}\n\n"

local blacklist = {
    ["TouchTransmitter"] = true,
    ["Camera"] = true,
    ["Terrain"] = true,
    ["Workspace"] = true,
    ["Status"] = true,
    ["ManualWeld"] = true,
    ["Weld"] = true,
    ["Motor6D"] = true,
    ["Snap"] = true
}

local defaultCache = {}

local function cleanValue(val)
    if typeof(val) == "string" then
        return '"' .. val .. '"'
    elseif typeof(val) == "Vector3" then
        return "Vector3.new(" .. tostring(val) .. ")"
    elseif typeof(val) == "Vector2" then
        return "Vector2.new(" .. tostring(val) .. ")"
    elseif typeof(val) == "CFrame" then
        return "CFrame.new(" .. tostring(val) .. ")"
    elseif typeof(val) == "Color3" then
        return "Color3.new(" .. tostring(val) .. ")"
    elseif typeof(val) == "BrickColor" then
        return "BrickColor.new(\"" .. tostring(val) .. "\")"
    elseif typeof(val) == "UDim2" then
        return "UDim2.new(" .. tostring(val) .. ")"
    elseif typeof(val) == "UDim" then
        return "UDim.new(" .. tostring(val) .. ")"
    elseif typeof(val) == "NumberRange" then
        return "NumberRange.new(" .. val.Min .. ", " .. val.Max .. ")"
    elseif typeof(val) == "EnumItem" then
        return tostring(val)
    elseif typeof(val) == "Instance" then
        return "nil"
    end
    return tostring(val)
end

local function getProperties(className)
    local props = {}
    if className == "Part" or className == "SpawnLocation" then
        props = {"Name", "Size", "CFrame", "BrickColor", "Shape", "CanCollide", "Anchored", "Material", "Transparency", "CastShadow"}
    elseif className == "MeshPart" or className == "WedgePart" or className == "CornerWedgePart" then
        props = {"Name", "Size", "CFrame", "BrickColor", "CanCollide", "Anchored", "Material", "Transparency", "CastShadow"}
    elseif className == "Decal" or className == "Texture" then
        props = {"Name", "Texture", "Face", "Transparency", "Color3"}
    elseif className == "SpecialMesh" then
        props = {"Name", "MeshId", "TextureId", "MeshType", "Scale", "Offset"}
    elseif className == "PointLight" or className == "SpotLight" or className == "SurfaceLight" then
        props = {"Name", "Color", "Brightness", "Range", "Enabled", "Shadows"}
    elseif className == "Sound" then
        props = {"Name", "SoundId", "Volume", "PlaybackSpeed", "Playing", "Looped", "PlayingOffset", "RollOffMaxDistance", "RollOffMinDistance", "RollOffMode"}
    elseif className == "Shirt" then
        props = {"Name", "ShirtTemplate"}
    elseif className == "Pants" then
        props = {"Name", "PantsTemplate"}
    elseif className == "BodyColors" then
        props = {"Name", "HeadColor3", "LeftArmColor3", "LeftLegColor3", "RightArmColor3", "RightLegColor3", "TorsoColor3"}
    elseif className == "Humanoid" then
        props = {"Name", "Health", "MaxHealth", "WalkSpeed", "JumpPower", "HipHeight", "DisplayDistanceType", "HealthDisplayType", "NameDisplayDistance", "RigType"}
    elseif className == "SurfaceGui" or className == "BillboardGui" then
        props = {"Name", "Enabled", "Active", "AlwaysOnTop", "LightInfluence", "MaxDistance", "Size", "StudsOffset", "Adornee", "Face"}
    elseif className == "Frame" then
        props = {"Name", "Visible", "Size", "Position", "BackgroundColor3", "BackgroundTransparency", "BorderSizePixel", "BorderColor3", "AnchorPoint", "ZIndex"}
    elseif className == "TextLabel" or className == "TextButton" or className == "TextBox" then
        props = {"Name", "Visible", "Size", "Position", "BackgroundColor3", "BackgroundTransparency", "BorderSizePixel", "BorderColor3", "AnchorPoint", "ZIndex", "Text", "TextColor3", "TextSize", "Font", "TextScaled", "TextTransparency", "TextStrokeColor3", "TextStrokeTransparency", "TextXAlignment", "TextYAlignment"}
    elseif className == "ImageLabel" or className == "ImageButton" then
        props = {"Name", "Visible", "Size", "Position", "BackgroundColor3", "BackgroundTransparency", "BorderSizePixel", "BorderColor3", "AnchorPoint", "ZIndex", "Image", "ImageColor3", "ImageTransparency", "ScaleType", "SliceCenter", "SliceScale"}
    elseif className == "UIAspectRatioConstraint" then
        props = {"Name", "AspectRatio", "AspectType", "DominantAxis"}
    elseif className == "UICorner" then
        props = {"Name", "CornerRadius"}
    elseif className == "UIGradient" then
        props = {"Name", "Color", "Transparency", "Enabled", "Rotation", "Offset"}
    elseif className == "UIStroke" then
        props = {"Name", "Color", "Thickness", "Transparency", "ApplyStrokeMode", "LineJoinMode", "Enabled"}
    elseif className == "UIPadding" then
        props = {"Name", "PaddingBottom", "PaddingLeft", "PaddingRight", "PaddingTop"}
    elseif className == "UIListLayout" or className == "UIGridLayout" then
        props = {"Name", "FillDirection", "HorizontalAlignment", "SortOrder", "VerticalAlignment", "Padding"}
    else
        props = {"Name"}
    end
    return props
end

local function getDefaultValue(className, prop)
    if not defaultCache[className] then
        defaultCache[className] = {}
        local success, defaultObj = pcall(function() return Instance.new(className) end)
        if success and defaultObj then
            local props = getProperties(className)
            for _, p in ipairs(props) do
                pcall(function()
                    defaultCache[className][p] = defaultObj[p]
                end)
            end
            defaultObj:Destroy()
        end
    end
    return defaultCache[className][prop]
end

local idCounter = 0
local opsCounter = 0 
local processedObjects = 0
local totalObjects = 0
local MAX_OPS_PER_FRAME = 1000

local function countObjects(obj)
    if blacklist[obj.ClassName] or obj:IsA("LuaSourceContainer") or obj:IsA("RemoteEvent") or obj:IsA("RemoteFunction") then 
        return 
    end
    totalObjects = totalObjects + 1
    for _, child in ipairs(obj:GetChildren()) do
        countObjects(child)
    end
end

local function serialize(obj, parentId)
    if blacklist[obj.ClassName] or obj:IsA("LuaSourceContainer") or obj:IsA("RemoteEvent") or obj:IsA("RemoteFunction") then 
        return 
    end

    idCounter = idCounter + 1
    local currentId = idCounter
    
    opsCounter = opsCounter + 1
    processedObjects = processedObjects + 1
    
    if opsCounter >= MAX_OPS_PER_FRAME then
        opsCounter = 0
        local percent = math.floor((processedObjects / totalObjects) * 100)
        print(string.format("Progress: %d%% (%d / %d instances)", percent, processedObjects, totalObjects))
        task.wait()
    end

    Output = Output .. string.format("v = create(\"%s\")\n", obj.ClassName)
    Output = Output .. string.format("refs[%d] = v\n", currentId)
    
    local props = getProperties(obj.ClassName)
    
    for _, prop in ipairs(props) do
        pcall(function()
            local currentVal = obj[prop]
            local defaultVal = getDefaultValue(obj.ClassName, prop)
            
            if currentVal ~= defaultVal then
                Output = Output .. string.format("v.%s = %s\n", prop, cleanValue(currentVal))
            end
        end)
    end
    
    if parentId then
        Output = Output .. string.format("v.Parent = refs[%d]\n\n", parentId)
    else
        Output = Output .. "v.Parent = game:GetService(\"Workspace\")\n\n"
    end
    
    for _, child in ipairs(obj:GetChildren()) do
        serialize(child, currentId)
    end
end

task.spawn(function()
    print("Counting objects...")
    for _, child in ipairs(Target:GetChildren()) do
        if not game:GetService("Players"):GetPlayerFromCharacter(child) then
            countObjects(child)
        end
    end
    
    print(string.format("Objects to serialize: %d. Starting dump...", totalObjects))
    Output = Output .. "local v\n"
    
    for _, child in ipairs(Target:GetChildren()) do
        if not game:GetService("Players"):GetPlayerFromCharacter(child) then
            serialize(child, nil)
        end
    end
    
    Output = Output .. "table.clear(refs)\n"

    if setclipboard or toclipboard then
        local clipFunc = setclipboard or toclipboard
        clipFunc(Output)
        print("Done! Copied to clipboard.")
    else
        print("Done! Clipboard not supported.")
    end
    
    table.clear(defaultCache)
end)

Features & Information

This script serializes in-game instances into executable Luau code for dynamic replication and generation. Instructions Execute the script and wait for the process to complete. The execution time depends on the size and density of the Workspace. Once finished, the generated code will be automatically copied to your clipboard. Built with AI: Gemini 3 Flash Version: 0.1 BETA

Community Comments (1)

LooeyLooeyAug 13, 2026(edited)

This is actually fire for mobile users

More Scripts for Universal Scripts