print("--//Made with Zfuscator\\--")

-- Define the Best Possible Obfuscator Function
function obfuscate(script)
    -- Helper Functions
    local function generateRandomName()
        return "var" .. math.random(1000000000, 9999999999)
    end

    local function generateRandomString(length)
        local chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
        local str = ''
        for i = 1, length do
            local rand = math.random(1, #chars)
            str = str .. chars:sub(rand, rand)
        end
        return str
    end

    local function encryptString(str, key)
        local encrypted = {}
        for i = 1, #str do
            local c = str:sub(i, i)
            local enc = string.format("\\x%02X", string.byte(c) ~ key)
            table.insert(encrypted, enc)
        end
        return table.concat(encrypted)
    end

    local function decryptString(str, key)
        return (str:gsub("\\x(%x%x)", function(hex)
            return string.char(tonumber(hex, 16) ~ key)
        end))
    end

    -- Generate random encryption key
    local key = math.random(1, 255)

    -- Variable and Function Renaming
    local renamed = {}
    local counter = 0
    script = script:gsub("%f[%a_](%w+)%f[^%w_]", function(var)
        if not renamed[var] then
            counter = counter + 1
            renamed[var] = generateRandomName()
        end
        return renamed[var]
    end)

    -- Encrypt Strings with Multi-layer Encryption
    script = script:gsub('"(.-)"', function(str)
        return '"..decryptString("' .. encryptString(str, key) .. '", ' .. key .. ').."'
    end)

    -- Add Decryption Function to the Script
    local decryptFunc = [[
        local function decryptString(str, key)
            return (str:gsub("\\x(%x%x)", function(hex)
                return string.char(tonumber(hex, 16) ~ key)
            end))
        end
    ]]

    -- Complex Control Flow Obfuscation
    local controlFlow = [[
        local function complexFlow()
            local function nestedFunc1(a)
                if a > 0 then
                    local function nestedFunc2(b)
                        if b % 3 == 0 then
                            local function nestedFunc3()
                                local x = 0
                                while x < 5 do
                                    local function nestedFunc4(c)
                                        local function nestedFunc5(d)
                                            if d > 2 then
                                                local function nestedFunc6()
                                                    local msg = "Hello from Roblox"
                                                    print(msg)
                                                end
                                                nestedFunc6()
                                            end
                                        end
                                        nestedFunc5(x + 2)
                                    end
                                    nestedFunc4(x)
                                    x = x + 1
                                end
                            end
                            nestedFunc3()
                        end
                    end
                    nestedFunc2(a)
                end
            end
            nestedFunc1(7)
        end
        complexFlow()
    ]]

    -- Extensive Dead Code Insertion
    local deadCode = "local function dummyFunction() " ..
                     "for i = 1, 2000 do local x = i * i end " ..
                     "end; dummyFunction(); local function extra() " ..
                     "local y = 0; while y < 200 do y = y + 1 end " ..
                     "end; extra(); "

    -- Dynamic Code Generation and Execution
    local dynamicCode = [[
        local function generateDynamicCode()
            return "]] .. script:gsub('"', '\\"') .. [["
        end
        local function executeDynamicCode()
            local dynamicCode = generateDynamicCode()
            local function execute(code)
                load(code)()
            end
            execute(dynamicCode)
        end
        executeDynamicCode()
    ]]

    -- Combine All Parts
    local obfuscatedScript = decryptFunc .. deadCode .. controlFlow .. dynamicCode

    -- Whitespace Removal & Code Flattening
    obfuscatedScript = obfuscatedScript:gsub("%s+", "") -- Remove whitespace and newlines
    obfuscatedScript = obfuscatedScript:gsub("\n", "") -- Remove newlines
    obfuscatedScript = obfuscatedScript:gsub("endend", "end") -- Flatten end statements

    return obfuscatedScript
end

-- Your Lua script to be obfuscated
local myScript = [[
    Script here! 
]]

-- Obfuscate the Script
local obfuscatedScript = obfuscate(myScript)

-- Print the Obfuscated Script (for debugging or review)
print(obfuscatedScript)

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: