executor (Previous version)
Key RequiredUniversal

executor (Previous version)

Universal ScriptKrScriptKrScript 1.3K views 171 executesUpdated Dec 6, 2025
5.0/ 5(2 votes)
20100% Positive
Lua Script•1691 lines (56045 chars)
local Players          = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local HttpService      = game:GetService("HttpService")
local RunService       = game:GetService("RunService")
local Stats            = game:GetService("Stats")
local TweenService     = game:GetService("TweenService")

local LocalPlayer = Players.LocalPlayer
local PlayerGui   = LocalPlayer:WaitForChild("PlayerGui")

-- GUI объект объявляем заранее, чтобы ErrorHandler мог к нему обращаться
local GUI = {}

-- время старта (для аптайма)
local ScriptStartTime = os.time()

--=====================================================================--
-- CONFIG
--=====================================================================--

local Config = {
    Prefix        = "/",        -- префикс команд в чате
    History       = {},         -- история запусков
    MaxHistory    = 10,
    TrustedMode   = true,       -- авто-повтор из истории / URL
    ToggleKey     = Enum.KeyCode.RightControl,
    SavedScripts  = {},         -- { {name="", code=""}, ... }
    SaveFileName  = "ProExecutor_Scripts.json",

    ConsoleLogs   = {},         -- логи консоли
    MaxConsoleLogs = 200,

    -- ScriptBlox
    ScriptBloxLastResults = {}  -- кеш последних результатов поиска
}

--=====================================================================--
-- ERROR HANDLER
--=====================================================================--

local ErrorHandler = {}

function ErrorHandler:Log(message, level)
    level = level or "INFO"
    warn(string.format("[Executor %s] %s", level, message))

    -- Пишем в внутреннюю консоль
    if GUI.AppendConsoleLog then
        GUI:AppendConsoleLog(level, message)
    else
        -- На старте, пока GUI ещё не инициализирован
        table.insert(Config.ConsoleLogs, 1, {
            time  = os.date("%H:%M:%S"),
            level = level,
            msg   = message
        })
    end
end

function ErrorHandler:SafeExecute(code, source)
    source = source or "unknown"
    if not code or code == "" then
        self:Log("Empty code, nothing to execute", "WARN")
        return false
    end

    local fn, loadErr = loadstring(code)
    if not fn then
        self:Log("Compile error: " .. tostring(loadErr), "ERROR")
        return false
    end

    -- Выполняем в максимально «нативной» среде (минимум следов)
    local env = getgenv and getgenv() or _G
    if setfenv then
        setfenv(fn, env)
    end

    local ok, runtimeErr = pcall(fn)
    if not ok then
        self:Log("Runtime error: " .. tostring(runtimeErr), "ERROR")
        return false
    end

    self:Log("Executed successfully from: " .. source, "SUCCESS")
    return true
end

--=====================================================================--
-- SAVE SYSTEM (SAVED SCRIPTS)
--=====================================================================--

local SaveSystem = {}

function SaveSystem:CanUseFiles()
    return typeof(writefile) == "function"
        and typeof(readfile) == "function"
        and typeof(isfile) == "function"
end

function SaveSystem:Load()
    if not self:CanUseFiles() then
        return
    end

    local okIsFile, exists = pcall(isfile, Config.SaveFileName)
    if not okIsFile or not exists then
        return
    end

    local okRead, data = pcall(readfile, Config.SaveFileName)
    if not okRead or not data or data == "" then
        return
    end

    local okDecode, decoded = pcall(function()
        return HttpService:JSONDecode(data)
    end)

    if okDecode and type(decoded) == "table" then
        Config.SavedScripts = decoded
        ErrorHandler:Log("Saved scripts loaded from file", "INFO")
    end
end

function SaveSystem:Save()
    if not self:CanUseFiles() then
        return
    end

    local okEncode, encoded = pcall(function()
        return HttpService:JSONEncode(Config.SavedScripts)
    end)

    if not okEncode then
        return
    end

    pcall(writefile, Config.SaveFileName, encoded)
end

--=====================================================================--
-- LOADER
--=====================================================================--

local Loader = {}

function Loader:AddToHistory(kind, value)
    local preview = value
    if kind == "code" then
        preview = value:gsub("\n", " ")
        if #preview > 80 then
            preview = preview:sub(1, 77) .. "..."
        end
    end

    table.insert(Config.History, 1, {
        kind   = kind,     -- "url" / "code"
        value  = value,    -- полное значение
        preview = preview
    })

    if #Config.History > Config.MaxHistory then
        table.remove(Config.History, #Config.History)
    end
end

function Loader:LoadFromURL(url)
    if not url or url == "" then
        ErrorHandler:Log("Empty URL", "ERROR")
        return false
    end

    local success, code = pcall(function()
        return game:HttpGet(url)
    end)

    if not success or not code then
        ErrorHandler:Log("Failed to load from URL: " .. tostring(url), "ERROR")
        return false
    end

    self:AddToHistory("url", url)
    return ErrorHandler:SafeExecute(code, url)
end

function Loader:ExecuteCode(code)
    if code == nil or code == "" then
        ErrorHandler:Log("No code to execute", "WARN")
        return false
    end
    self:AddToHistory("code", code)
    return ErrorHandler:SafeExecute(code, "direct code")
end

function Loader:ReExecuteFromHistory(index, editorBox)
    local entry = Config.History[index]
    if not entry then return false end

    if entry.kind == "url" then
        if Config.TrustedMode then
            return self:LoadFromURL(entry.value)
        else
            ErrorHandler:Log("TrustedMode OFF: клик загрузил URL в редактор, затем Execute", "WARN")
            if editorBox then
                editorBox.Text = entry.value
            end
            return false
        end
    elseif entry.kind == "code" then
        if editorBox then
            editorBox.Text = entry.value
        end
        if Config.TrustedMode then
            return self:ExecuteCode(entry.value)
        else
            ErrorHandler:Log("Code загружен из истории. Нажми Execute для запуска.", "INFO")
            return false
        end
    end

    return false
end

-- Saved scripts

function Loader:AddSavedScript(name, code)
    if not name or name == "" then
        ErrorHandler:Log("Script name is empty", "ERROR")
        return
    end
    if not code or code == "" then
        ErrorHandler:Log("Script code is empty", "ERROR")
        return
    end

    local entry = { name = name, code = code }

    -- Обновляем, если такое имя уже есть
    local updated = false
    for i, v in ipairs(Config.SavedScripts) do
        if v.name == name then
            Config.SavedScripts[i] = entry
            updated = true
            break
        end
    end

    if not updated then
        table.insert(Config.SavedScripts, 1, entry)
    end

    SaveSystem:Save()
    ErrorHandler:Log("Script '" .. name .. "' saved", "INFO")
end

function Loader:ExecuteSaved(index, editorBox)
    local entry = Config.SavedScripts[index]
    if not entry then
        return false
    end
    if editorBox then
        editorBox.Text = entry.code
    end
    return ErrorHandler:SafeExecute(entry.code, "saved:" .. (entry.name or "unnamed"))
end

--=====================================================================--
-- SCRIPTBLOX API (поиск скриптов)
--=====================================================================--

local ScriptBlox = {}

-- Базовые URL. Если ScriptBlox поменяет API, нужно будет обновить эти строки.
ScriptBlox.SearchEndpoint    = "https://scriptblox.com/api/script/search?q=%s&mode=free"
ScriptBlox.GetScriptEndpoint = "https://scriptblox.com/api/script/getscript?id=%s"

-- Универсальный HTTP GET с обработкой ошибок
local function safeHttpGet(url)
    local ok, res = pcall(function()
        return game:HttpGet(url)
    end)
    if not ok then
        ErrorHandler:Log("HTTP error: " .. tostring(res), "ERROR")
        return nil
    end
    return res
end

-- Поиск скриптов по запросу (и опционально по текущей игре)
function ScriptBlox:Search(query, placeId)
    query = query or ""
    local encodedQuery = HttpService:UrlEncode(query)
    local url = string.format(self.SearchEndpoint, encodedQuery)

    if placeId then
        -- поиск конкретно по текущей игре
        url = url .. "&game=" .. tostring(placeId)
    end

    local body = safeHttpGet(url)
    if not body then
        ErrorHandler:Log("ScriptBlox search failed (no response)", "ERROR")
        return {}
    end

    local ok, data = pcall(function()
        return HttpService:JSONDecode(body)
    end)

    if not ok or type(data) ~= "table" then
        ErrorHandler:Log("ScriptBlox JSON decode failed", "ERROR")
        return {}
    end

    -- В разных версиях API список может лежать в разных полях
    local list = nil
    if type(data.result) == "table" and type(data.result.scripts) == "table" then
        list = data.result.scripts
    elseif type(data.scripts) == "table" then
        list = data.scripts
    elseif type(data.data) == "table" then
        list = data.data
    end

    if not list or #list == 0 then
        ErrorHandler:Log("ScriptBlox: no scripts found", "WARN")
        return {}
    end

    local results = {}
    for _, item in ipairs(list) do
        if type(item) == "table" then
            local id = item.id or item._id or item.scriptId or item.scriptid
            if id then
                table.insert(results, {
                    id    = tostring(id),
                    title = item.title or item.name or "No title",
                    game  = (item.game and (item.game.name or item.game)) or item.gameName or "Unknown game",
                    views = item.views or item.viewsCount or 0
                })
            end
        end
    end

    return results
end

-- Получение реального кода скрипта по ID
function ScriptBlox:GetScriptCode(scriptId)
    if not scriptId then
        return nil
    end
    local encodedId = HttpService:UrlEncode(tostring(scriptId))
    local url = string.format(self.GetScriptEndpoint, encodedId)

    local body = safeHttpGet(url)
    if not body then
        ErrorHandler:Log("ScriptBlox getscript failed (no response)", "ERROR")
        return nil
    end

    local ok, data = pcall(function()
        return HttpService:JSONDecode(body)
    end)

    if not ok or type(data) ~= "table" then
        -- Иногда ScriptBlox отдает сразу raw-скрипт, без JSON
        if type(body) == "string" and #body > 0 then
            return body
        end

        ErrorHandler:Log("ScriptBlox getscript JSON decode failed", "ERROR")
        return nil
    end

    local scriptText = data.script or data.code or data.rawScript or data.content
    if not scriptText or scriptText == "" then
        ErrorHandler:Log("ScriptBlox: script field is empty", "ERROR")
        return nil
    end

    return scriptText
end

--=====================================================================--
-- CHAT COMMAND: /load <url>
--=====================================================================--

LocalPlayer.Chatted:Connect(function(message)
    if message:sub(1, 1) ~= Config.Prefix then return end

    local cmd = message:sub(2)
    if cmd:lower():find("^load%s+") then
        local url = cmd:match("^load%s+(.+)")
        if url and url ~= "" then
            Loader:LoadFromURL(url)
        else
            ErrorHandler:Log("Usage: /load <url>", "ERROR")
        end
    end
end)

--=====================================================================--
-- GUI
--=====================================================================--

local ScreenGui = Instance.new("ScreenGui")
ScreenGui.Name = "ProScriptExecutorGUI"
ScreenGui.ResetOnSpawn = false
ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
ScreenGui.Enabled = true
ScreenGui.IgnoreGuiInset = true
ScreenGui.Parent = PlayerGui

local MainFrame = Instance.new("Frame")
MainFrame.Name = "MainFrame"
MainFrame.Size = UDim2.new(0.8, 0, 0.8, 0) -- адаптивно под разные экраны
MainFrame.Position = UDim2.new(0.1, 0, 0.1, 0)
MainFrame.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
MainFrame.BorderSizePixel = 0
MainFrame.Parent = ScreenGui
MainFrame.Visible = false -- покажем после анимации

local mainCorner = Instance.new("UICorner")
mainCorner.CornerRadius = UDim.new(0, 8)
mainCorner.Parent = MainFrame

-- легкая рамка-неон
local MainStroke = Instance.new("UIStroke")
MainStroke.Color = Color3.fromRGB(0, 170, 255)
MainStroke.Thickness = 1.5
MainStroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
MainStroke.Parent = MainFrame

-- масштаб для анимаций
local MainScale = Instance.new("UIScale")
MainScale.Scale = 1
MainScale.Parent = MainFrame

GUI.MainFrame = MainFrame
GUI.MainScale = MainScale

-- Title bar (для перетаскивания)
local TitleBar = Instance.new("Frame")
TitleBar.Name = "TitleBar"
TitleBar.Size = UDim2.new(1, 0, 0, 28)
TitleBar.Position = UDim2.new(0, 0, 0, 0)
TitleBar.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
TitleBar.BorderSizePixel = 0
TitleBar.Parent = MainFrame

local titleCorner = Instance.new("UICorner")
titleCorner.CornerRadius = UDim.new(0, 8)
titleCorner.Parent = TitleBar

-- градиент на тайлбаре (оригинальный эффект)
local TitleGradient = Instance.new("UIGradient")
TitleGradient.Color = ColorSequence.new({
    ColorSequenceKeypoint.new(0, Color3.fromRGB(0, 170, 255)),
    ColorSequenceKeypoint.new(1, Color3.fromRGB(170, 0, 255))
})
TitleGradient.Rotation = 0
TitleGradient.Parent = TitleBar

RunService.RenderStepped:Connect(function()
    TitleGradient.Rotation = (TitleGradient.Rotation + 0.15) % 360
end)

local TitleLabel = Instance.new("TextLabel")
TitleLabel.Name = "TitleLabel"
TitleLabel.Size = UDim2.new(1, -80, 1, 0)
TitleLabel.Position = UDim2.new(0, 8, 0, 0)
TitleLabel.BackgroundTransparency = 1
TitleLabel.Text = "Pro Script Executor v3.2 (RightCtrl - show/hide)"
TitleLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
TitleLabel.Font = Enum.Font.SourceSansBold
TitleLabel.TextSize = 14
TitleLabel.TextXAlignment = Enum.TextXAlignment.Left
TitleLabel.Parent = TitleBar

local CloseButton = Instance.new("TextButton")
CloseButton.Name = "CloseButton"
CloseButton.Size = UDim2.new(0, 24, 0, 24)
CloseButton.Position = UDim2.new(1, -28, 0.5, -12)
CloseButton.BackgroundColor3 = Color3.fromRGB(180, 60, 60)
CloseButton.Text = "X"
CloseButton.TextColor3 = Color3.fromRGB(255, 255, 255)
CloseButton.Font = Enum.Font.SourceSansBold
CloseButton.TextSize = 14
CloseButton.Parent = TitleBar

local MinButton = Instance.new("TextButton")
MinButton.Name = "MinButton"
MinButton.Size = UDim2.new(0, 24, 0, 24)
MinButton.Position = UDim2.new(1, -56, 0.5, -12)
MinButton.BackgroundColor3 = Color3.fromRGB(90, 90, 90)
MinButton.Text = "-"
MinButton.TextColor3 = Color3.fromRGB(255, 255, 255)
MinButton.Font = Enum.Font.SourceSansBold
MinButton.TextSize = 18
MinButton.Parent = TitleBar

-- TAB BAR
local TabBar = Instance.new("Frame")
TabBar.Name = "TabBar"
TabBar.Size = UDim2.new(1, -10, 0, 26)
TabBar.Position = UDim2.new(0, 5, 0, 30)
TabBar.BackgroundTransparency = 1
TabBar.Parent = MainFrame

local function makeTabButton(name, text, relPosX)
    local btn = Instance.new("TextButton")
    btn.Name = name
    btn.Size = UDim2.new(0.18, 0, 1, 0)   -- чуть меньше, чтобы влезли 5 табов
    btn.Position = UDim2.new(relPosX, 0, 0, 0)
    btn.BackgroundColor3 = Color3.fromRGB(55, 55, 55)
    btn.TextColor3 = Color3.fromRGB(255, 255, 255)
    btn.Font = Enum.Font.SourceSansBold
    btn.TextSize = 14
    btn.Text = text
    btn.Parent = TabBar

    local c = Instance.new("UICorner")
    c.CornerRadius = UDim.new(0, 4)
    c.Parent = btn

    return btn
end

local ExecutorTabButton = makeTabButton("ExecutorTab", "Executor", 0.00)
local ServerTabButton   = makeTabButton("ServerTab",   "Server",   0.20)
local SavedTabButton    = makeTabButton("SavedTab",    "Saved",    0.40)
local ConsoleTabButton  = makeTabButton("ConsoleTab",  "Console",  0.60)
local SearchTabButton   = makeTabButton("SearchTab",   "Search",   0.80) -- ScriptBlox

-- CONTENT AREA
local ContentFrame = Instance.new("Frame")
ContentFrame.Name = "ContentFrame"
ContentFrame.Size = UDim2.new(1, -10, 1, -60)
ContentFrame.Position = UDim2.new(0, 5, 0, 58)
ContentFrame.BackgroundTransparency = 1
ContentFrame.Parent = MainFrame

-- Pages
local ExecutorPage = Instance.new("Frame")
ExecutorPage.Name = "ExecutorPage"
ExecutorPage.Size = UDim2.new(1, 0, 1, 0)
ExecutorPage.Position = UDim2.new(0, 0, 0, 0)
ExecutorPage.BackgroundTransparency = 1
ExecutorPage.Parent = ContentFrame

local ServerPage = Instance.new("Frame")
ServerPage.Name = "ServerPage"
ServerPage.Size = UDim2.new(1, 0, 1, 0)
ServerPage.Position = UDim2.new(0, 0, 0, 0)
ServerPage.BackgroundTransparency = 1
ServerPage.Visible = false
ServerPage.Parent = ContentFrame

local SavedPage = Instance.new("Frame")
SavedPage.Name = "SavedPage"
SavedPage.Size = UDim2.new(1, 0, 1, 0)
SavedPage.Position = UDim2.new(0, 0, 0, 0)
SavedPage.BackgroundTransparency = 1
SavedPage.Visible = false
SavedPage.Parent = ContentFrame

local ConsolePage = Instance.new("Frame")
ConsolePage.Name = "ConsolePage"
ConsolePage.Size = UDim2.new(1, 0, 1, 0)
ConsolePage.Position = UDim2.new(0, 0, 0, 0)
ConsolePage.BackgroundTransparency = 1
ConsolePage.Visible = false
ConsolePage.Parent = ContentFrame

local SearchPage = Instance.new("Frame")  -- ScriptBlox
SearchPage.Name = "SearchPage"
SearchPage.Size = UDim2.new(1, 0, 1, 0)
SearchPage.Position = UDim2.new(0, 0, 0, 0)
SearchPage.BackgroundTransparency = 1
SearchPage.Visible = false
SearchPage.Parent = ContentFrame

--============================ EXECUTOR PAGE ===========================--

-- Многострочный редактор кода + скролл
local CodeScroll = Instance.new("ScrollingFrame")
CodeScroll.Name = "CodeScroll"
CodeScroll.Size = UDim2.new(0.6, -10, 0.7, -10)
CodeScroll.Position = UDim2.new(0.02, 0, 0.05, 0)
CodeScroll.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
CodeScroll.BorderSizePixel = 0
CodeScroll.CanvasSize = UDim2.new(0, 0, 0, 0)
CodeScroll.ScrollBarThickness = 6
CodeScroll.Parent = ExecutorPage

local csCorner = Instance.new("UICorner")
csCorner.CornerRadius = UDim.new(0, 4)
csCorner.Parent = CodeScroll

local CodeBox = Instance.new("TextBox")
CodeBox.Name = "CodeBox"
CodeBox.Size = UDim2.new(1, -6, 1, -6)
CodeBox.Position = UDim2.new(0, 3, 0, 3)
CodeBox.BackgroundTransparency = 1
CodeBox.TextColor3 = Color3.fromRGB(255, 255, 255)
CodeBox.Font = Enum.Font.Code
CodeBox.PlaceholderText = "-- Paste your script here or write code..."
CodeBox.Text = ""
CodeBox.TextSize = 14
CodeBox.TextXAlignment = Enum.TextXAlignment.Left
CodeBox.TextYAlignment = Enum.TextYAlignment.Top
CodeBox.ClearTextOnFocus = false
CodeBox.MultiLine = true
CodeBox.Parent = CodeScroll

CodeBox:GetPropertyChangedSignal("TextBounds"):Connect(function()
    local tb = CodeBox.TextBounds
    CodeScroll.CanvasSize = UDim2.new(0, 0, 0, tb.Y + 10)
end)

-- Панель кнопок под редактором
local ButtonBar = Instance.new("Frame")
ButtonBar.Name = "ButtonBar"
ButtonBar.Size = UDim2.new(0.6, -10, 0, 40)
ButtonBar.Position = UDim2.new(0.02, 0, 0.8, 0)
ButtonBar.BackgroundTransparency = 1
ButtonBar.Parent = ExecutorPage

local function makeButton(parent, name, text, relPosX)
    local btn = Instance.new("TextButton")
    btn.Name = name
    btn.Size = UDim2.new(0, 90, 0, 28)
    btn.Position = UDim2.new(relPosX, 0, 0, 6)
    btn.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
    btn.TextColor3 = Color3.fromRGB(255, 255, 255)
    btn.Font = Enum.Font.SourceSans
    btn.TextSize = 14
    btn.Text = text
    btn.Parent = parent

    local c = Instance.new("UICorner")
    c.CornerRadius = UDim.new(0, 4)
    c.Parent = btn

    return btn
end

local ExecuteButton = makeButton(ButtonBar, "ExecuteButton", "Execute", 0.0)
local ClearButton   = makeButton(ButtonBar, "ClearButton",   "Clear",   0.32)
local CopyButton    = makeButton(ButtonBar, "CopyButton",    "Copy",    0.64)
local PasteButton   = makeButton(ButtonBar, "PasteButton",   "Paste",   0.96)

-- Блок URL ввода и статус + история справа
local UrlBox = Instance.new("TextBox")
UrlBox.Name = "UrlBox"
UrlBox.Size = UDim2.new(0.35, -10, 0, 28)
UrlBox.Position = UDim2.new(0.63, 0, 0.05, 0)
UrlBox.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
UrlBox.TextColor3 = Color3.fromRGB(255, 255, 255)
UrlBox.Font = Enum.Font.Code
UrlBox.TextSize = 12
UrlBox.PlaceholderText = "Paste script URL here..."
UrlBox.ClearTextOnFocus = true
UrlBox.Parent = ExecutorPage

local urlCorner = Instance.new("UICorner")
urlCorner.CornerRadius = UDim.new(0, 4)
urlCorner.Parent = UrlBox

local UrlLoadButton = Instance.new("TextButton")
UrlLoadButton.Name = "UrlLoadButton"
UrlLoadButton.Size = UDim2.new(0.35, -10, 0, 24)
UrlLoadButton.Position = UDim2.new(0.63, 0, 0.05, 32)
UrlLoadButton.BackgroundColor3 = Color3.fromRGB(0, 150, 255)
UrlLoadButton.TextColor3 = Color3.fromRGB(255, 255, 255)
UrlLoadButton.Font = Enum.Font.SourceSans
UrlLoadButton.TextSize = 14
UrlLoadButton.Text = "Load & Execute URL"
UrlLoadButton.Parent = ExecutorPage

local urlBtnCorner = Instance.new("UICorner")
urlBtnCorner.CornerRadius = UDim.new(0, 4)
urlBtnCorner.Parent = UrlLoadButton

local StatusLabel = Instance.new("TextLabel")
StatusLabel.Name = "StatusLabel"
StatusLabel.Size = UDim2.new(0.35, -10, 0, 24)
StatusLabel.Position = UDim2.new(0.63, 0, 0.05, 64)
StatusLabel.BackgroundTransparency = 1
StatusLabel.Text = "Ready"
StatusLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
StatusLabel.Font = Enum.Font.SourceSans
StatusLabel.TextSize = 13
StatusLabel.TextXAlignment = Enum.TextXAlignment.Left
StatusLabel.Parent = ExecutorPage

local HistoryLabel = Instance.new("TextLabel")
HistoryLabel.Name = "HistoryLabel"
HistoryLabel.Size = UDim2.new(0.35, -80, 0, 20)
HistoryLabel.Position = UDim2.new(0.63, 0, 0.05, 96)
HistoryLabel.BackgroundTransparency = 1
HistoryLabel.Text = "History (0)"
HistoryLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
HistoryLabel.Font = Enum.Font.SourceSansBold
HistoryLabel.TextSize = 13
HistoryLabel.TextXAlignment = Enum.TextXAlignment.Left
HistoryLabel.Parent = ExecutorPage

local ClearHistoryButton = Instance.new("TextButton")
ClearHistoryButton.Name = "ClearHistoryButton"
ClearHistoryButton.Size = UDim2.new(0, 70, 0, 20)
ClearHistoryButton.Position = UDim2.new(1, -75, 0.05, 96)
ClearHistoryButton.BackgroundColor3 = Color3.fromRGB(90, 90, 90)
ClearHistoryButton.TextColor3 = Color3.fromRGB(255, 255, 255)
ClearHistoryButton.Font = Enum.Font.SourceSans
ClearHistoryButton.TextSize = 12
ClearHistoryButton.Text = "Clear"
ClearHistoryButton.Parent = ExecutorPage

local chCorner = Instance.new("UICorner")
chCorner.CornerRadius = UDim.new(0, 4)
chCorner.Parent = ClearHistoryButton

local HistoryFrame = Instance.new("ScrollingFrame")
HistoryFrame.Name = "HistoryFrame"
HistoryFrame.Size = UDim2.new(0.35, -10, 0.6, 0)
HistoryFrame.Position = UDim2.new(0.63, 0, 0.05, 120)
HistoryFrame.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
HistoryFrame.BorderSizePixel = 0
HistoryFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
HistoryFrame.ScrollBarThickness = 6
HistoryFrame.Parent = ExecutorPage

local hCorner = Instance.new("UICorner")
hCorner.CornerRadius = UDim.new(0, 4)
hCorner.Parent = HistoryFrame

function GUI:RefreshHistory()
    for _, child in ipairs(HistoryFrame:GetChildren()) do
        if child:IsA("TextButton") then
            child:Destroy()
        end
    end

    HistoryLabel.Text = "History (" .. #Config.History .. ")"
    HistoryFrame.CanvasSize = UDim2.new(0, 0, 0, #Config.History * 24)

    for i, entry in ipairs(Config.History) do
        local btn = Instance.new("TextButton")
        btn.Name = "HistoryItem_" .. i
        btn.Size = UDim2.new(1, -6, 0, 22)
        btn.Position = UDim2.new(0, 3, 0, (i - 1) * 24)
        btn.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
        btn.TextColor3 = Color3.fromRGB(255, 255, 255)
        btn.Font = Enum.Font.SourceSans
        btn.TextSize = 12
        local prefix = entry.kind == "url" and "[URL] " or "[CODE] "
        btn.Text = prefix .. entry.preview
        btn.TextXAlignment = Enum.TextXAlignment.Left
        btn.Parent = HistoryFrame

        local c = Instance.new("UICorner")
        c.CornerRadius = UDim.new(0, 3)
        c.Parent = btn

        btn.MouseButton1Click:Connect(function()
            local ok = Loader:ReExecuteFromHistory(i, CodeBox)
            if ok then
                StatusLabel.Text = "History executed."
                StatusLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
            else
                StatusLabel.Text = "History loaded into editor."
                StatusLabel.TextColor3 = Color3.fromRGB(255, 255, 0)
            end
        end)
    end
end

--============================= SERVER PAGE ============================--

local ServerTitle = Instance.new("TextLabel")
ServerTitle.Name = "ServerTitle"
ServerTitle.Size = UDim2.new(1, -10, 0, 24)
ServerTitle.Position = UDim2.new(0, 5, 0, 5)
ServerTitle.BackgroundTransparency = 1
ServerTitle.Text = "Server / Game Information"
ServerTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
ServerTitle.Font = Enum.Font.SourceSansBold
ServerTitle.TextSize = 16
ServerTitle.TextXAlignment = Enum.TextXAlignment.Left
ServerTitle.Parent = ServerPage

local function makeInfoLabel(order, name)
    local lbl = Instance.new("TextLabel")
    lbl.Name = name
    lbl.Size = UDim2.new(1, -10, 0, 20)
    lbl.Position = UDim2.new(0, 5, 0, 5 + 24 + (order - 1) * 22)
    lbl.BackgroundTransparency = 1
    lbl.Text = name .. ": ..."
    lbl.TextColor3 = Color3.fromRGB(220, 220, 220)
    lbl.Font = Enum.Font.SourceSans
    lbl.TextSize = 14
    lbl.TextXAlignment = Enum.TextXAlignment.Left
    lbl.Parent = ServerPage
    return lbl
end

local GameNameLabel   = makeInfoLabel(1,  "Game")
local PlaceIdLabel    = makeInfoLabel(2,  "PlaceId")
local JobIdLabel      = makeInfoLabel(3,  "JobId")
local PlayerCountLbl  = makeInfoLabel(4,  "Players")
local PingLabel       = makeInfoLabel(5,  "Ping")
local FPSLabel        = makeInfoLabel(6,  "FPS")
local PlaceVersionLbl = makeInfoLabel(7,  "PlaceVersion")
local ServerTypeLbl   = makeInfoLabel(8,  "ServerType")
local LocalPlayerLbl  = makeInfoLabel(9,  "LocalPlayer")
local AccountAgeLbl   = makeInfoLabel(10, "AccountAge")
local UptimeLabel     = makeInfoLabel(11, "Uptime")
local MemoryLabel     = makeInfoLabel(12, "Memory")

-- FPS вычисление
local currentFPS = 0
RunService.RenderStepped:Connect(function(dt)
    if dt > 0 then
        currentFPS = math.floor(1 / dt + 0.5)
    end
end)

task.spawn(function()
    local placeId = game.PlaceId
    local jobId   = game.JobId
    local gameName = "Unknown"
    pcall(function()
        gameName = game:GetService("MarketplaceService"):GetProductInfo(placeId).Name
    end)

    local placeVersion = tonumber(game.PlaceVersion) or 0

    while true do
        task.wait(1)
        if not ScreenGui.Parent then break end

        local playersList = Players:GetPlayers()
        local playerCount = #playersList

        local pingStr = "N/A"
        local pingItem = Stats.Network.ServerStatsItem["Data Ping"]
        if pingItem then
            pingStr = pingItem:GetValueString()
        end

        local memoryStr = "N/A"
        pcall(function()
            local mem = Stats:GetTotalMemoryUsageMb()
            memoryStr = string.format("%.1f MB", mem)
        end)

        local serverType = "Public"
        pcall(function()
            if game.PrivateServerId and game.PrivateServerId ~= "" then
                serverType = "Private"
            end
        end)

        local accountAgeDays = LocalPlayer.AccountAge or 0
        local uptimeSec = os.time() - ScriptStartTime
        local h = math.floor(uptimeSec / 3600)
        local m = math.floor((uptimeSec % 3600) / 60)
        local s = uptimeSec % 60
        local uptimeStr = string.format("%02d:%02d:%02d", h, m, s)

        local names = {}
        for _, plr in ipairs(playersList) do
            table.insert(names, plr.Name)
        end

        GameNameLabel.Text   = "Game: " .. tostring(gameName)
        PlaceIdLabel.Text    = "PlaceId: " .. tostring(placeId)
        JobIdLabel.Text      = "JobId: " .. tostring(jobId)
        PlayerCountLbl.Text  = "Players: " .. tostring(playerCount) .. " [" .. table.concat(names, ", ") .. "]"
        PingLabel.Text       = "Ping: " .. tostring(pingStr)
        FPSLabel.Text        = "FPS: " .. tostring(currentFPS)
        PlaceVersionLbl.Text = "PlaceVersion: " .. tostring(placeVersion)
        ServerTypeLbl.Text   = "ServerType: " .. serverType
        LocalPlayerLbl.Text  = "LocalPlayer: " .. LocalPlayer.Name .. " (ID: " .. tostring(LocalPlayer.UserId) .. ")"
        AccountAgeLbl.Text   = "AccountAge: " .. tostring(accountAgeDays) .. " days"
        UptimeLabel.Text     = "Uptime: " .. uptimeStr
        MemoryLabel.Text     = "Memory: " .. memoryStr
    end
end)

--============================= SAVED PAGE =============================--

local SavedTitle = Instance.new("TextLabel")
SavedTitle.Name = "SavedTitle"
SavedTitle.Size = UDim2.new(1, -10, 0, 24)
SavedTitle.Position = UDim2.new(0, 5, 0, 5)
SavedTitle.BackgroundTransparency = 1
SavedTitle.Text = "Saved Scripts"
SavedTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
SavedTitle.Font = Enum.Font.SourceSansBold
SavedTitle.TextSize = 16
SavedTitle.TextXAlignment = Enum.TextXAlignment.Left
SavedTitle.Parent = SavedPage

local SavedNameBox = Instance.new("TextBox")
SavedNameBox.Name = "SavedNameBox"
SavedNameBox.Size = UDim2.new(0.4, -10, 0, 26)
SavedNameBox.Position = UDim2.new(0, 5, 0, 34)
SavedNameBox.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
SavedNameBox.TextColor3 = Color3.fromRGB(255, 255, 255)
SavedNameBox.Font = Enum.Font.Code
SavedNameBox.TextSize = 13
SavedNameBox.PlaceholderText = "Script name..."
SavedNameBox.ClearTextOnFocus = true
SavedNameBox.Parent = SavedPage

local snCorner = Instance.new("UICorner")
snCorner.CornerRadius = UDim.new(0, 4)
snCorner.Parent = SavedNameBox

local SaveScriptButton = Instance.new("TextButton")
SaveScriptButton.Name = "SaveScriptButton"
SaveScriptButton.Size = UDim2.new(0.25, 0, 0, 26)
SaveScriptButton.Position = UDim2.new(0.42, 0, 0, 34)
SaveScriptButton.BackgroundColor3 = Color3.fromRGB(0, 160, 100)
SaveScriptButton.TextColor3 = Color3.fromRGB(255, 255, 255)
SaveScriptButton.Font = Enum.Font.SourceSans
SaveScriptButton.TextSize = 14
SaveScriptButton.Text = "Save current code"
SaveScriptButton.Parent = SavedPage

local ssCorner = Instance.new("UICorner")
ssCorner.CornerRadius = UDim.new(0, 4)
ssCorner.Parent = SaveScriptButton

local SavedInfoLabel = Instance.new("TextLabel")
SavedInfoLabel.Name = "SavedInfoLabel"
SavedInfoLabel.Size = UDim2.new(0.3, -10, 0, 26)
SavedInfoLabel.Position = UDim2.new(0.7, 0, 0, 34)
SavedInfoLabel.BackgroundTransparency = 1
SavedInfoLabel.Text = "File autosave: " .. (SaveSystem:CanUseFiles() and "ON" or "OFF")
SavedInfoLabel.TextColor3 = Color3.fromRGB(200, 200, 200)
SavedInfoLabel.Font = Enum.Font.SourceSans
SavedInfoLabel.TextSize = 12
SavedInfoLabel.TextXAlignment = Enum.TextXAlignment.Right
SavedInfoLabel.Parent = SavedPage

local SavedListLabel = Instance.new("TextLabel")
SavedListLabel.Name = "SavedListLabel"
SavedListLabel.Size = UDim2.new(1, -10, 0, 20)
SavedListLabel.Position = UDim2.new(0, 5, 0, 66)
SavedListLabel.BackgroundTransparency = 1
SavedListLabel.Text = "Saved scripts (0)"
SavedListLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
SavedListLabel.Font = Enum.Font.SourceSansBold
SavedListLabel.TextSize = 13
SavedListLabel.TextXAlignment = Enum.TextXAlignment.Left
SavedListLabel.Parent = SavedPage

local SavedListFrame = Instance.new("ScrollingFrame")
SavedListFrame.Name = "SavedListFrame"
SavedListFrame.Size = UDim2.new(1, -10, 1, -90)
SavedListFrame.Position = UDim2.new(0, 5, 0, 90)
SavedListFrame.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
SavedListFrame.BorderSizePixel = 0
SavedListFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
SavedListFrame.ScrollBarThickness = 6
SavedListFrame.Parent = SavedPage

local slCorner = Instance.new("UICorner")
slCorner.CornerRadius = UDim.new(0, 4)
slCorner.Parent = SavedListFrame

function GUI:RefreshSavedList()
    for _, child in ipairs(SavedListFrame:GetChildren()) do
        if child:IsA("TextButton") then
            child:Destroy()
        end
    end

    SavedListLabel.Text = "Saved scripts (" .. #Config.SavedScripts .. ")"
    SavedListFrame.CanvasSize = UDim2.new(0, 0, 0, #Config.SavedScripts * 26)

    for i, entry in ipairs(Config.SavedScripts) do
        local btn = Instance.new("TextButton")
        btn.Name = "SavedItem_" .. i
        btn.Size = UDim2.new(1, -6, 0, 24)
        btn.Position = UDim2.new(0, 3, 0, (i - 1) * 26)
        btn.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
        btn.TextColor3 = Color3.fromRGB(255, 255, 255)
        btn.Font = Enum.Font.SourceSans
        btn.TextSize = 13
        btn.Text = "[" .. tostring(entry.name) .. "]"
        btn.TextXAlignment = Enum.TextXAlignment.Left
        btn.Parent = SavedListFrame

        local c = Instance.new("UICorner")
        c.CornerRadius = UDim.new(0, 3)
        c.Parent = btn

        btn.MouseButton1Click:Connect(function()
            local ok = Loader:ExecuteSaved(i, CodeBox)
            if ok then
                StatusLabel.Text = "Saved script executed."
                StatusLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
                GUI:SwitchTab("Executor")
            else
                StatusLabel.Text = "Saved script failed."
                StatusLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
                GUI:SwitchTab("Executor")
            end
        end)
    end
end

--============================= CONSOLE PAGE ===========================--

local ConsoleTitle = Instance.new("TextLabel")
ConsoleTitle.Name = "ConsoleTitle"
ConsoleTitle.Size = UDim2.new(1, -10, 0, 24)
ConsoleTitle.Position = UDim2.new(0, 5, 0, 5)
ConsoleTitle.BackgroundTransparency = 1
ConsoleTitle.Text = "Console (logs & errors)"
ConsoleTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
ConsoleTitle.Font = Enum.Font.SourceSansBold
ConsoleTitle.TextSize = 16
ConsoleTitle.TextXAlignment = Enum.TextXAlignment.Left
ConsoleTitle.Parent = ConsolePage

local ConsoleInfoLabel = Instance.new("TextLabel")
ConsoleInfoLabel.Name = "ConsoleInfoLabel"
ConsoleInfoLabel.Size = UDim2.new(0.5, -10, 0, 20)
ConsoleInfoLabel.Position = UDim2.new(0, 5, 0, 34)
ConsoleInfoLabel.BackgroundTransparency = 1
ConsoleInfoLabel.Text = "Console logs (0)"
ConsoleInfoLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
ConsoleInfoLabel.Font = Enum.Font.SourceSans
ConsoleInfoLabel.TextSize = 13
ConsoleInfoLabel.TextXAlignment = Enum.TextXAlignment.Left
ConsoleInfoLabel.Parent = ConsolePage

local ClearConsoleButton = Instance.new("TextButton")
ClearConsoleButton.Name = "ClearConsoleButton"
ClearConsoleButton.Size = UDim2.new(0, 100, 0, 22)
ClearConsoleButton.Position = UDim2.new(1, -110, 0, 34)
ClearConsoleButton.BackgroundColor3 = Color3.fromRGB(90, 90, 90)
ClearConsoleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
ClearConsoleButton.Font = Enum.Font.SourceSans
ClearConsoleButton.TextSize = 12
ClearConsoleButton.Text = "Clear Console"
ClearConsoleButton.Parent = ConsolePage

local ccCorner = Instance.new("UICorner")
ccCorner.CornerRadius = UDim.new(0, 4)
ccCorner.Parent = ClearConsoleButton

local ConsoleFrame = Instance.new("ScrollingFrame")
ConsoleFrame.Name = "ConsoleFrame"
ConsoleFrame.Size = UDim2.new(1, -10, 1, -60)
ConsoleFrame.Position = UDim2.new(0, 5, 0, 60)
ConsoleFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
ConsoleFrame.BorderSizePixel = 0
ConsoleFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
ConsoleFrame.ScrollBarThickness = 6
ConsoleFrame.Parent = ConsolePage

local cfCorner = Instance.new("UICorner")
cfCorner.CornerRadius = UDim.new(0, 4)
cfCorner.Parent = ConsoleFrame

function GUI:RefreshConsole()
    if not ConsoleFrame then return end

    for _, child in ipairs(ConsoleFrame:GetChildren()) do
        if child:IsA("TextLabel") then
            child:Destroy()
        end
    end

    local count = #Config.ConsoleLogs
    ConsoleInfoLabel.Text = "Console logs (" .. count .. ")"
    ConsoleFrame.CanvasSize = UDim2.new(0, 0, 0, count * 22)

    for i, log in ipairs(Config.ConsoleLogs) do
        local lbl = Instance.new("TextLabel")
        lbl.Name = "Log_" .. i
        lbl.Size = UDim2.new(1, -6, 0, 20)
        lbl.Position = UDim2.new(0, 3, 0, (i - 1) * 22)
        lbl.BackgroundTransparency = 1
        lbl.Font = Enum.Font.Code
        lbl.TextSize = 12
        lbl.TextXAlignment = Enum.TextXAlignment.Left

        local prefix = string.format("[%s] [%s]", log.time or "??", log.level or "?")
        lbl.Text = prefix .. " " .. (log.msg or "")

        if log.level == "ERROR" then
            lbl.TextColor3 = Color3.fromRGB(255, 80, 80)
        elseif log.level == "WARN" then
            lbl.TextColor3 = Color3.fromRGB(255, 200, 0)
        elseif log.level == "SUCCESS" then
            lbl.TextColor3 = Color3.fromRGB(0, 255, 128)
        else
            lbl.TextColor3 = Color3.fromRGB(220, 220, 220)
        end

        lbl.Parent = ConsoleFrame
    end
end

function GUI:AppendConsoleLog(level, message)
    local entry = {
        time  = os.date("%H:%M:%S"),
        level = level,
        msg   = message
    }
    table.insert(Config.ConsoleLogs, 1, entry)
    if #Config.ConsoleLogs > Config.MaxConsoleLogs then
        table.remove(Config.ConsoleLogs, #Config.ConsoleLogs)
    end
    self:RefreshConsole()
end

ClearConsoleButton.MouseButton1Click:Connect(function()
    Config.ConsoleLogs = {}
    GUI:RefreshConsole()
end)

--============================= SCRIPTBLOX PAGE ========================--

local SearchTitle = Instance.new("TextLabel")
SearchTitle.Name = "SearchTitle"
SearchTitle.Size = UDim2.new(1, -10, 0, 24)
SearchTitle.Position = UDim2.new(0, 5, 0, 5)
SearchTitle.BackgroundTransparency = 1
SearchTitle.Text = "ScriptBlox Search"
SearchTitle.TextColor3 = Color3.fromRGB(255, 255, 255)
SearchTitle.Font = Enum.Font.SourceSansBold
SearchTitle.TextSize = 16
SearchTitle.TextXAlignment = Enum.TextXAlignment.Left
SearchTitle.Parent = SearchPage

local SearchBox = Instance.new("TextBox")
SearchBox.Name = "SearchBox"
SearchBox.Size = UDim2.new(0.5, -10, 0, 26)
SearchBox.Position = UDim2.new(0, 5, 0, 34)
SearchBox.BackgroundColor3 = Color3.fromRGB(45, 45, 45)
SearchBox.TextColor3 = Color3.fromRGB(255, 255, 255)
SearchBox.Font = Enum.Font.Code
SearchBox.TextSize = 13
SearchBox.PlaceholderText = "Search by script name / game / keyword..."
SearchBox.ClearTextOnFocus = true
SearchBox.Parent = SearchPage

local sbCorner = Instance.new("UICorner")
sbCorner.CornerRadius = UDim.new(0, 4)
sbCorner.Parent = SearchBox

local SearchButton = Instance.new("TextButton")
SearchButton.Name = "SearchButton"
SearchButton.Size = UDim2.new(0.2, 0, 0, 26)
SearchButton.Position = UDim2.new(0.52, 0, 0, 34)
SearchButton.BackgroundColor3 = Color3.fromRGB(0, 150, 255)
SearchButton.TextColor3 = Color3.fromRGB(255, 255, 255)
SearchButton.Font = Enum.Font.SourceSans
SearchButton.TextSize = 14
SearchButton.Text = "Search"
SearchButton.Parent = SearchPage

local sbtnCorner = Instance.new("UICorner")
sbtnCorner.CornerRadius = UDim.new(0, 4)
sbtnCorner.Parent = SearchButton

local SearchGameButton = Instance.new("TextButton")
SearchGameButton.Name = "SearchGameButton"
SearchGameButton.Size = UDim2.new(0.22, 0, 0, 26)
SearchGameButton.Position = UDim2.new(0.74, 0, 0, 34)
SearchGameButton.BackgroundColor3 = Color3.fromRGB(0, 180, 120)
SearchGameButton.TextColor3 = Color3.fromRGB(255, 255, 255)
SearchGameButton.Font = Enum.Font.SourceSans
SearchGameButton.TextSize = 13
SearchGameButton.Text = "This Game"
SearchGameButton.Parent = SearchPage

local sgbCorner = Instance.new("UICorner")
sgbCorner.CornerRadius = UDim.new(0, 4)
sgbCorner.Parent = SearchGameButton

local SearchInfoLabel = Instance.new("TextLabel")
SearchInfoLabel.Name = "SearchInfoLabel"
SearchInfoLabel.Size = UDim2.new(1, -10, 0, 20)
SearchInfoLabel.Position = UDim2.new(0, 5, 0, 66)
SearchInfoLabel.BackgroundTransparency = 1
SearchInfoLabel.Text = "Results: 0"
SearchInfoLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
SearchInfoLabel.Font = Enum.Font.SourceSans
SearchInfoLabel.TextSize = 13
SearchInfoLabel.TextXAlignment = Enum.TextXAlignment.Left
SearchInfoLabel.Parent = SearchPage

local SearchResultsFrame = Instance.new("ScrollingFrame")
SearchResultsFrame.Name = "SearchResultsFrame"
SearchResultsFrame.Size = UDim2.new(1, -10, 1, -94)
SearchResultsFrame.Position = UDim2.new(0, 5, 0, 90)
SearchResultsFrame.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
SearchResultsFrame.BorderSizePixel = 0
SearchResultsFrame.CanvasSize = UDim2.new(0, 0, 0, 0)
SearchResultsFrame.ScrollBarThickness = 6
SearchResultsFrame.Parent = SearchPage

local srfCorner = Instance.new("UICorner")
srfCorner.CornerRadius = UDim.new(0, 4)
srfCorner.Parent = SearchResultsFrame

function GUI:RefreshScriptBloxResults()
    for _, child in ipairs(SearchResultsFrame:GetChildren()) do
        if child:IsA("TextButton") then
            child:Destroy()
        end
    end

    local list = Config.ScriptBloxLastResults
    local count = #list
    SearchInfoLabel.Text = "Results: " .. count
    SearchResultsFrame.CanvasSize = UDim2.new(0, 0, 0, count * 28)

    for i, item in ipairs(list) do
        local btn = Instance.new("TextButton")
        btn.Name = "Result_" .. i
        btn.Size = UDim2.new(1, -6, 0, 26)
        btn.Position = UDim2.new(0, 3, 0, (i - 1) * 28)
        btn.BackgroundColor3 = Color3.fromRGB(50, 50, 50)
        btn.TextColor3 = Color3.fromRGB(255, 255, 255)
        btn.Font = Enum.Font.SourceSans
        btn.TextSize = 13
        btn.TextXAlignment = Enum.TextXAlignment.Left
        btn.Text = string.format("[%s] %s (views: %s)", item.game or "?", item.title or "No title", tostring(item.views or 0))
        btn.Parent = SearchResultsFrame

        local c = Instance.new("UICorner")
        c.CornerRadius = UDim.new(0, 3)
        c.Parent = btn

        btn.MouseButton1Click:Connect(function()
            -- Загрузка скрипта из ScriptBlox
            StatusLabel.Text = "Loading ScriptBlox script..."
            StatusLabel.TextColor3 = Color3.fromRGB(255, 255, 0)

            local code = ScriptBlox:GetScriptCode(item.id)
            if not code or code == "" then
                StatusLabel.Text = "ScriptBlox script load failed."
                StatusLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
                return
            end

            CodeBox.Text = code
            GUI:SwitchTab("Executor")

            if Config.TrustedMode then
                GUI:PlayExecuteAnimation()
                local ok = Loader:ExecuteCode(code)
                if ok then
                    StatusLabel.Text = "ScriptBlox script executed: " .. (item.title or "")
                    StatusLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
                else
                    StatusLabel.Text = "ScriptBlox script failed."
                    StatusLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
                end
                GUI:RefreshHistory()
            else
                StatusLabel.Text = "Script from ScriptBlox loaded into editor."
                StatusLabel.TextColor3 = Color3.fromRGB(255, 255, 0)
            end
        end)
    end
end

local function doScriptBloxSearch(query, byGame)
    if (not query or query == "") and not byGame then
        SearchInfoLabel.Text = "Enter search text"
        SearchInfoLabel.TextColor3 = Color3.fromRGB(255, 200, 0)
        return
    end

    SearchInfoLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
    SearchInfoLabel.Text = "Searching ScriptBlox..."

    task.spawn(function()
        local placeId = byGame and game.PlaceId or nil
        local results = ScriptBlox:Search(query, placeId)
        Config.ScriptBloxLastResults = results
        GUI:RefreshScriptBloxResults()

        if #results == 0 then
            SearchInfoLabel.Text = "No results."
            SearchInfoLabel.TextColor3 = Color3.fromRGB(255, 200, 0)
        else
            SearchInfoLabel.Text = "Results: " .. tostring(#results)
            SearchInfoLabel.TextColor3 = Color3.fromRGB(220, 220, 220)
        end
    end)
end

SearchButton.MouseButton1Click:Connect(function()
    doScriptBloxSearch(SearchBox.Text, false)
end)

SearchGameButton.MouseButton1Click:Connect(function()
    doScriptBloxSearch(SearchBox.Text, true)
end)

--=====================================================================--
-- BUTTONS LOGIC + АНИМАЦИЯ ЗАПУСКА СКРИПТА
--=====================================================================--

function GUI:PlayExecuteAnimation()
    -- тонкая линия подсветки снизу MainFrame при запуске скрипта
    local highlight = Instance.new("Frame")
    highlight.Name = "ExecHighlight"
    highlight.Size = UDim2.new(0, 0, 0, 2)
    highlight.Position = UDim2.new(0, 0, 1, -2)
    highlight.BackgroundColor3 = Color3.fromRGB(0, 255, 127)
    highlight.BorderSizePixel = 0
    highlight.Parent = MainFrame

    local tweenIn = TweenService:Create(
        highlight,
        TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
        { Size = UDim2.new(1, 0, 0, 2) }
    )
    tweenIn:Play()
    tweenIn.Completed:Connect(function()
        local tweenOut = TweenService:Create(
            highlight,
            TweenInfo.new(0.25, Enum.EasingStyle.Quad, Enum.EasingDirection.In),
            { BackgroundTransparency = 1 }
        )
        tweenOut:Play()
        tweenOut.Completed:Connect(function()
            highlight:Destroy()
        end)
    end)
end

ExecuteButton.MouseButton1Click:Connect(function()
    local src = CodeBox.Text
    if src == nil or src == "" then
        return
    end

    GUI:PlayExecuteAnimation()

    StatusLabel.Text = "Executing..."
    StatusLabel.TextColor3 = Color3.fromRGB(255, 255, 0)

    local ok = Loader:ExecuteCode(src)
    if ok then
        StatusLabel.Text = "Executed!"
        StatusLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
    else
        StatusLabel.Text = "Execution failed."
        StatusLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
    end
    GUI:RefreshHistory()
end)

ClearButton.MouseButton1Click:Connect(function()
    CodeBox.Text = ""
end)

CopyButton.MouseButton1Click:Connect(function()
    local ok = pcall(function()
        if setclipboard then
            setclipboard(CodeBox.Text or "")
        end
    end)
    if ok then
        StatusLabel.Text = "Copied to clipboard."
        StatusLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
    else
        StatusLabel.Text = "Copy not supported."
        StatusLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
    end
end)

PasteButton.MouseButton1Click:Connect(function()
    local text = ""
    pcall(function()
        if getclipboard then
            text = getclipboard() or ""
        end
    end)
    if text ~= "" then
        CodeBox.Text = text
        StatusLabel.Text = "Pasted from clipboard."
        StatusLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
    else
        StatusLabel.Text = "Clipboard empty or unsupported."
        StatusLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
    end
end)

UrlLoadButton.MouseButton1Click:Connect(function()
    local url = UrlBox.Text
    if not url or url == "" then return end

    GUI:PlayExecuteAnimation()

    StatusLabel.Text = "Loading URL..."
    StatusLabel.TextColor3 = Color3.fromRGB(255, 255, 0)

    local ok = Loader:LoadFromURL(url)
    if ok then
        StatusLabel.Text = "URL executed!"
        StatusLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
    else
        StatusLabel.Text = "URL failed."
        StatusLabel.TextColor3 = Color3.fromRGB(255, 0, 0)
    end
    GUI:RefreshHistory()
end)

SaveScriptButton.MouseButton1Click:Connect(function()
    local name = SavedNameBox.Text
    local code = CodeBox.Text
    Loader:AddSavedScript(name, code)
    GUI:RefreshSavedList()
end)

ClearHistoryButton.MouseButton1Click:Connect(function()
    Config.History = {}
    GUI:RefreshHistory()
    StatusLabel.Text = "History cleared."
    StatusLabel.TextColor3 = Color3.fromRGB(0, 255, 0)
end)

--=====================================================================--
-- TABS LOGIC (с анимацией табов)
--=====================================================================--

function GUI:SwitchTab(tabName)
    ExecutorPage.Visible = (tabName == "Executor")
    ServerPage.Visible   = (tabName == "Server")
    SavedPage.Visible    = (tabName == "Saved")
    ConsolePage.Visible  = (tabName == "Console")
    SearchPage.Visible   = (tabName == "Search")

    local function animateTab(btn, active)
        local targetColor = active and Color3.fromRGB(0, 140, 220) or Color3.fromRGB(55, 55, 55)
        TweenService:Create(
            btn,
            TweenInfo.new(0.2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
            { BackgroundColor3 = targetColor }
        ):Play()
    end

    animateTab(ExecutorTabButton, tabName == "Executor")
    animateTab(ServerTabButton,   tabName == "Server")
    animateTab(SavedTabButton,    tabName == "Saved")
    animateTab(ConsoleTabButton,  tabName == "Console")
    animateTab(SearchTabButton,   tabName == "Search")
end

ExecutorTabButton.MouseButton1Click:Connect(function()
    GUI:SwitchTab("Executor")
end)

ServerTabButton.MouseButton1Click:Connect(function()
    GUI:SwitchTab("Server")
end)

SavedTabButton.MouseButton1Click:Connect(function()
    GUI:SwitchTab("Saved")
end)

ConsoleTabButton.MouseButton1Click:Connect(function()
    GUI:SwitchTab("Console")
end)

SearchTabButton.MouseButton1Click:Connect(function()
    GUI:SwitchTab("Search")
end)

GUI:SwitchTab("Executor")

--=====================================================================--
-- DRAGGABLE WINDOW
--=====================================================================--

do
    local dragging = false
    local dragInput, dragStart, startPos

    local function update(input)
        local delta = input.Position - dragStart
        MainFrame.Position = UDim2.new(
            startPos.X.Scale,
            startPos.X.Offset + delta.X,
            startPos.Y.Scale,
            startPos.Y.Offset + delta.Y
        )
    end

    TitleBar.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or
           input.UserInputType == Enum.UserInputType.Touch then

            dragging = true
            dragStart = input.Position
            startPos = MainFrame.Position

            input.Changed:Connect(function()
                if input.UserInputState == Enum.UserInputState.End then
                    dragging = false
                end
            end)
        end
    end)

    TitleBar.InputChanged:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseMovement or
           input.UserInputType == Enum.UserInputType.Touch then
            dragInput = input
        end
    end)

    UserInputService.InputChanged:Connect(function(input)
        if input == dragInput and dragging then
            update(input)
        end
    end)
end

--=====================================================================--
-- TOGGLE / CLOSE / MINIMIZE + АНИМАЦИЯ UI
--=====================================================================--

function GUI:PlayIntroAnimation()
    if not self.MainScale then return end
    MainFrame.Visible = true
    self.MainScale.Scale = 0.7
    local tweenInfo = TweenInfo.new(0.35, Enum.EasingStyle.Back, Enum.EasingDirection.Out)
    TweenService:Create(self.MainScale, tweenInfo, { Scale = 1 }):Play()
end

function GUI:ShowSplash()
    local splash = Instance.new("Frame")
    splash.Name = "Splash"
    splash.Size = UDim2.new(0, 260, 0, 90)
    splash.Position = UDim2.new(0.5, -130, 0.5, -45)
    splash.BackgroundColor3 = Color3.fromRGB(10, 10, 10)
    splash.BackgroundTransparency = 0.1
    splash.BorderSizePixel = 0
    splash.Parent = ScreenGui

    local c = Instance.new("UICorner")
    c.CornerRadius = UDim.new(0, 8)
    c.Parent = splash

    local title = Instance.new("TextLabel")
    title.Size = UDim2.new(1, -10, 0, 30)
    title.Position = UDim2.new(0, 5, 0, 5)
    title.BackgroundTransparency = 1
    title.Text = "Pro Script Executor"
    title.TextColor3 = Color3.fromRGB(255, 255, 255)
    title.Font = Enum.Font.SourceSansBold
    title.TextSize = 18
    title.Parent = splash

    local sub = Instance.new("TextLabel")
    sub.Size = UDim2.new(1, -10, 0, 20)
    sub.Position = UDim2.new(0, 5, 0, 35)
    sub.BackgroundTransparency = 1
    sub.Text = "Initializing..."
    sub.TextColor3 = Color3.fromRGB(180, 180, 180)
    sub.Font = Enum.Font.SourceSans
    sub.TextSize = 14
    sub.Parent = splash

    local barBg = Instance.new("Frame")
    barBg.Size = UDim2.new(1, -20, 0, 6)
    barBg.Position = UDim2.new(0, 10, 0, 65)
    barBg.BackgroundColor3 = Color3.fromRGB(30, 30, 30)
    barBg.BorderSizePixel = 0
    barBg.Parent = splash

    local barCorner = Instance.new("UICorner")
    barCorner.CornerRadius = UDim.new(0, 3)
    barCorner.Parent = barBg

    local barFill = Instance.new("Frame")
    barFill.Size = UDim2.new(0, 0, 1, 0)
    barFill.Position = UDim2.new(0, 0, 0, 0)
    barFill.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
    barFill.BorderSizePixel = 0
    barFill.Parent = barBg

    local fillCorner = Instance.new("UICorner")
    fillCorner.CornerRadius = UDim.new(0, 3)
    fillCorner.Parent = barFill

    TweenService:Create(
        barFill,
        TweenInfo.new(0.7, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
        { Size = UDim2.new(1, 0, 1, 0) }
    ):Play()

    task.delay(1.0, function()
        local fade = TweenService:Create(
            splash,
            TweenInfo.new(0.3, Enum.EasingStyle.Quad, Enum.EasingDirection.Out),
            { BackgroundTransparency = 1 }
        )
        fade:Play()
        fade.Completed:Connect(function()
            splash:Destroy()
            GUI:PlayIntroAnimation()
        end)
    end)
end

CloseButton.MouseButton1Click:Connect(function()
    ScreenGui.Enabled = false
end)

MinButton.MouseButton1Click:Connect(function()
    MainFrame.Visible = not MainFrame.Visible
end)

local function ToggleGui()
    ScreenGui.Enabled = not ScreenGui.Enabled
    if ScreenGui.Enabled then
        GUI:PlayIntroAnimation()
    end
end

UserInputService.InputBegan:Connect(function(input, gpe)
    if gpe then return end
    if input.KeyCode == Config.ToggleKey then
        ToggleGui()
    end
end)

-- Мобильная кнопка-тоггл
if UserInputService.TouchEnabled then
    local MobileToggle = Instance.new("TextButton")
    MobileToggle.Name = "MobileToggle"
    MobileToggle.Size = UDim2.new(0, 40, 0, 40)
    MobileToggle.Position = UDim2.new(1, -50, 1, -50)
    MobileToggle.BackgroundColor3 = Color3.fromRGB(0, 140, 220)
    MobileToggle.Text = "EX"
    MobileToggle.TextColor3 = Color3.fromRGB(255, 255, 255)
    MobileToggle.Font = Enum.Font.SourceSansBold
    MobileToggle.TextSize = 16
    MobileToggle.Parent = ScreenGui

    local c = Instance.new("UICorner")
    c.CornerRadius = UDim.new(1, 0)
    c.Parent = MobileToggle

    MobileToggle.MouseButton1Click:Connect(function()
        ToggleGui()
    end)
end

--=====================================================================--
-- INIT / RESPAWN HANDLING
--=====================================================================--

SaveSystem:Load()
GUI:RefreshHistory()
GUI:RefreshSavedList()
GUI:RefreshConsole()
GUI:RefreshScriptBloxResults()
ErrorHandler:Log("Pro Script Executor loaded (with ScriptBlox Search).", "INFO")

GUI:ShowSplash()

LocalPlayer.CharacterAdded:Connect(function()
    task.wait(1)
    ScreenGui.Parent = LocalPlayer:WaitForChild("PlayerGui")
end)

LocalPlayer.AncestryChanged:Connect(function()
    if not LocalPlayer.Parent then
        ScreenGui:Destroy()
    end
end)

Features & Information

Note:The script is mine, this is the first version therefore, it is not laid out in a fake form. ————————————————— Link Execution Chat commands for link execution Bypassing the anti-detection Script hub script blocks Information about the server Saving scripts Script execution history ——————————————- Future plans: Redo the script completely rework And improve the anti-detection Add a key to obtain a non-counterfeit code for copyright protection
#Executor#Undetect#free#Byp*ing#Universal

Community Comments (14)

KrScriptKrScriptDec 6, 2025

I hope you enjoy it :)

Replying to @KrScript
RobinsonFRobinsonFDec 6, 2025

@KrScript love it!!! There’s one issue the history box is leaking over at the bottom of the gui window… you should make this as it’s On executor:) love the simple and smooth design

KrScriptKrScriptDec 6, 2025

Thanks, I'll keep it in mind in the next version.

KrScriptKrScriptDec 6, 2025

Go to my discord where the keys to my scripts will be https://discord.gg/VPYxejNUE

Replying to @KrScript
gerryl1gerryl1Dec 13, 2025

@KrScript how can i remove -inf coins???

Malik_25msMalik_25msDec 6, 2025

ai

KrScriptKrScriptDec 6, 2025

@AZ_SCRIBT What does that have to do with it

sneakysquid1422sneakysquid1422Dec 7, 2025

is this a server sided executor?

Replying to @sneakysquid1422
KrScriptKrScriptDec 7, 2025

@sneakysquid1422 In the future, I plan to create a server executor function.

KrScriptKrScriptDec 7, 2025

No

gerryl1gerryl1Dec 13, 2025

how can i remove -inf coins???

gerryl1gerryl1Dec 13, 2025

how can i remove -inf coins???

gerryl1gerryl1Dec 13, 2025

how can i remove -inf coins???

gerryl1gerryl1Dec 13, 2025

how can i remove -inf coins???

More Scripts for Universal Scripts