Jujutsu: Zero Script Roblox | Auto Redeem Codes, Auto Clan Spins

PUBLISHEDUPDATED
What changed
  • 2026-11-04 — Added Script #4: enjoy! & More.
  • 2026-10-30 — Added Script #3: it has auto farm auto raid auto everything & More.
Verified Working2 Active Scripts100% Free

This is the fast track method to a much easier Jujutsu: Zero experience on Roblox, completely bypassing the frustrating, time-wasting steps of other methods.

You can forget the scripts that force you through endless timers, and frustrating blockers. I created this to run smoothly and reliably in the game.

This Jujutsu: Zero script is comes with highly useful features designed to make your gameplay simpler, more enjoyable, and genuinely better.

Script Features:

  • Auto Farm
  • Kill All

Tip – Always use a high UNC and sUNC executor and consider testing scripts on an alt Roblox account first. If you’re ready to go, just copy the code below and paste it into your executor to get started safely.

Jujutsu: Zero Script:

Auto Redeem Codes & Auto Spin

Working ScriptFree
loadstring(game:HttpGet("https://raw.githubusercontent.com/snarix/AutoSpinZero/refs/heads/main/Main"))()
Compatible executors: HydrogenMacSploitAWP.GGDelta

Auto Farm

Working ScriptFree
loadstring(game:HttpGet("https://api.luarmor.net/files/v3/loaders/3186a4f30fcd853ae613dcbee2534612.lua"))()
Compatible executors: HydrogenMacSploitAWP.GGDelta

Script #3 it has auto farm auto raid auto everything & More

Script #3 · it has auto farm auto raid auto everything & MoreFree
it has auto farm auto raid auto everything
-- [[ Rscripts Risk Notice ]]
-- This script is not verified by rscripts.net. Deal with caution.
--
-- Stay safe:
--   • Never log in on unofficial Roblox sites or lookalike domains.
--   • Real Roblox links use roblox.com (check the .com ending).
--   • Treat fake Roblox login / "claim reward" pages as phishing.
-- [[ End Rscripts Risk Notice ]]


local Players         = game:GetService("Players")
local player          = Players.LocalPlayer
local playerGui       = player:WaitForChild("PlayerGui")

local DISCORD_URL   = "https://discord.gg/zQbQJH5rMb"
local GATE_SECONDS  = 15
local LOADER_URL    = "https://raw.githubusercontent.com/poookey55-sudo/Hunter_Hub/refs/heads/main/Heko_Source_Obfuscated.lua"

local uc = {
	Panel     = Color3.fromRGB(10, 8, 8),
	Surface   = Color3.fromRGB(24, 10, 10),
	Border    = Color3.fromRGB(96, 28, 28),
	Text      = Color3.fromRGB(245, 235, 235),
	Muted     = Color3.fromRGB(170, 120, 120),
	On        = Color3.fromRGB(220, 55, 55),
	Discord   = Color3.fromRGB(200, 35, 35),
}

local function make(className, props, parent)
	local inst = Instance.new(className)
	for k, v in pairs(props) do inst[k] = v end
	inst.Parent = parent
	return inst
end

local function corner(parent, radius)
	make("UICorner", { CornerRadius = UDim.new(0, radius) }, parent)
end

local function copyDiscord()
	pcall(function()
		if setclipboard then
			setclipboard(DISCORD_URL)
		elseif toclipboard then
			toclipboard(DISCORD_URL)
		end
	end)
end

-- =========================================================
-- SPLASH — Discord gate, 15s countdown, then onDone()
-- =========================================================
local function showSplash(onDone)
	local splash = make("ScreenGui", {
		Name = "HackingBrosSplash",
		ResetOnSpawn = false,
		IgnoreGuiInset = true,
		DisplayOrder = 200,
	}, playerGui)

	make("Frame", {
		Size = UDim2.fromScale(1, 1),
		BackgroundColor3 = Color3.new(0, 0, 0),
		BackgroundTransparency = 0.35,
		BorderSizePixel = 0,
	}, splash)

	local card = make("Frame", {
		Size = UDim2.fromOffset(460, 300),
		Position = UDim2.fromScale(0.5, 0.5),
		AnchorPoint = Vector2.new(0.5, 0.5),
		BackgroundColor3 = uc.Panel,
		BorderSizePixel = 0,
	}, splash)
	corner(card, 14)
	make("UIStroke", { Color = uc.Border, Thickness = 1 }, card)

	make("TextLabel", {
		Size = UDim2.new(1, -40, 0, 26),
		Position = UDim2.fromOffset(20, 22),
		BackgroundTransparency = 1,
		Text = "HACKING BROS",
		Font = Enum.Font.GothamBold,
		TextSize = 20,
		TextColor3 = uc.On,
		TextXAlignment = Enum.TextXAlignment.Left,
	}, card)

	make("TextLabel", {
		Size = UDim2.new(1, -40, 0, 16),
		Position = UDim2.fromOffset(20, 50),
		BackgroundTransparency = 1,
		Text = "SCRIPT LOADER · JOIN DISCORD",
		Font = Enum.Font.Gotham,
		TextSize = 11,
		TextColor3 = uc.On,
		TextXAlignment = Enum.TextXAlignment.Left,
	}, card)

	make("TextLabel", {
		Size = UDim2.new(1, -40, 0, 60),
		Position = UDim2.fromOffset(20, 76),
		BackgroundTransparency = 1,
		Text = "Copy the invite link and hop in for the full release. The script below auto-loads once the timer runs out.",
		Font = Enum.Font.Gotham,
		TextSize = 13,
		TextColor3 = uc.Muted,
		TextWrapped = true,
		TextXAlignment = Enum.TextXAlignment.Left,
		TextYAlignment = Enum.TextYAlignment.Top,
	}, card)

	local linkBox = make("TextLabel", {
		Size = UDim2.new(1, -40, 0, 38),
		Position = UDim2.fromOffset(20, 148),
		BackgroundColor3 = uc.Surface,
		BorderSizePixel = 0,
		Text = "discord.gg/zQbQJH5rMb",
		Font = Enum.Font.Code,
		TextSize = 14,
		TextColor3 = uc.Text,
	}, card)
	corner(linkBox, 8)
	make("UIStroke", { Color = uc.Border, Thickness = 1 }, linkBox)

	local copyBtn = make("TextButton", {
		Size = UDim2.new(1, -40, 0, 40),
		Position = UDim2.fromOffset(20, 198),
		BackgroundColor3 = uc.Discord,
		BorderSizePixel = 0,
		Text = "Copy Discord Invite",
		Font = Enum.Font.GothamBold,
		TextSize = 14,
		TextColor3 = uc.Text,
		AutoButtonColor = false,
	}, card)
	corner(copyBtn, 8)

	copyBtn.Activated:Connect(function()
		copyDiscord()
		copyBtn.Text = "Copied — see you inside ✓"
		copyBtn.BackgroundColor3 = uc.On
		copyBtn.TextColor3 = Color3.new(0, 0, 0)
	end)

	local countdown = make("TextLabel", {
		Size = UDim2.new(1, -40, 0, 20),
		Position = UDim2.new(0, 20, 1, -38),
		BackgroundTransparency = 1,
		Text = ("Script loads in %ds…"):format(GATE_SECONDS),
		Font = Enum.Font.Gotham,
		TextSize = 12,
		TextColor3 = uc.Muted,
		TextXAlignment = Enum.TextXAlignment.Left,
	}, card)

	local start = os.clock()
	task.spawn(function()
		while true do
			local remaining = math.max(0, math.ceil(GATE_SECONDS - (os.clock() - start)))
			countdown.Text = ("Script loads in %ds…"):format(remaining)
			if remaining <= 0 then break end
			task.wait(0.1)
		end
		splash:Destroy()
		onDone()
	end)
end

-- =========================================================
-- PERSISTENT DISCORD BUTTON (top-right, survives loader)
-- =========================================================
local function buildDiscordButton()
	local gui = make("ScreenGui", {
		Name = "HackingBrosPersistent",
		ResetOnSpawn = false,
		ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
		DisplayOrder = 150,
	}, playerGui)

	local bar = make("Frame", {
		Name = "DiscordBar",
		Size = UDim2.fromOffset(280, 40),
		Position = UDim2.new(1, -20, 0, 20),
		AnchorPoint = Vector2.new(1, 0),
		BackgroundColor3 = uc.Panel,
		BorderSizePixel = 0,
	}, gui)
	corner(bar, 8)
	make("UIStroke", { Color = uc.Discord, Thickness = 1 }, bar)

	local btn = make("TextButton", {
		Size = UDim2.fromScale(1, 1),
		BackgroundTransparency = 1,
		Text = "",
		AutoButtonColor = false,
	}, bar)

	local label = make("TextLabel", {
		Size = UDim2.new(1, -28, 1, 0),
		Position = UDim2.fromOffset(12, 0),
		BackgroundTransparency = 1,
		Text = "Join DC for more awsum scripts for free",
		Font = Enum.Font.GothamBold,
		TextSize = 12,
		TextColor3 = uc.Text,
		TextXAlignment = Enum.TextXAlignment.Left,
	}, btn)

	make("TextLabel", {
		Size = UDim2.fromOffset(18, 18),
		Position = UDim2.new(1, -24, 0.5, -9),
		BackgroundTransparency = 1,
		Text = "›",
		Font = Enum.Font.GothamBold,
		TextSize = 16,
		TextColor3 = uc.On,
	}, btn)

	btn.Activated:Connect(function()
		copyDiscord()
		label.Text = "Link copied ✓"
		task.delay(1.4, function()
			if label.Parent then
				label.Text = "Join DC for more awsum scripts for free"
			end
		end)
	end)
end

-- =========================================================
-- FIRE LOADER
-- =========================================================
local function runLoader()
	local ok, err = pcall(function()
		loadstring(game:HttpGet(LOADER_URL))()
	end)
	if not ok then
		warn("[HackingBros] loader failed: " .. tostring(err))
	end
end

-- =========================================================
-- RUN
-- =========================================================
showSplash(function()
	buildDiscordButton()
	runLoader()
end)
Executor compatibility changes over time. Check current reports before testing.

Script #4 enjoy! & More

Script #4 · enjoy! & MoreFree
enjoy!dc: waitwhatismyuser
--normal
-- ============================================================
-- OJBS Suite — custom GUI, RightCtrl rail, three modules
-- ============================================================
if getgenv().OJBS_Cleanup then pcall(getgenv().OJBS_Cleanup) end

local Players           = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService        = game:GetService("RunService")
local UIS               = game:GetService("UserInputService")
local TweenService      = game:GetService("TweenService")
local HttpService       = game:GetService("HttpService")
local Workspace         = game:GetService("Workspace")

local LP    = Players.LocalPlayer
local Mouse = LP:GetMouse()

local TOGGLE_KEY = Enum.KeyCode.RightControl
local USE_EMOJI  = true
local WINDOW_W, WINDOW_H = 600, 442
local RAIL_W, RAIL_OFF  = 58, 24
local TAB_W = 84
local MOTION = 1.4   -- global multiplier on every tween duration

local FONT_MONO  = Enum.Font.Code    -- body / values
local FONT_TITLE = Enum.Font.Arcade  -- titles / badge

-- everything below is persisted to CONFIG_FILE
local STYLE = {
    bg      = { m1 = "studs", tp = "crt", crate = "grid" },
    opacity = 0.55,  -- pattern strength 0..1
    scan    = true,  -- scanline overlay
    glow    = true,  -- halos behind widgets
    round   = 4,     -- corner radius cap, px (0 = sharp)
    outline = 1,     -- stroke thickness multiplier
    scale   = 1,     -- window scale
    image   = { m1 = "", tp = "", crate = "" },  -- per-window background source
    imgTrans = 0.5,  -- image transparency 0..1
    imgFit  = "Crop",
}
local BG_KINDS = { "classic", "studs", "grid", "crt" }
local STYLE_DEFAULT = {
    bg      = { m1 = "studs", tp = "crt", crate = "grid" },
    opacity = 0.55,
    scan    = true,
    glow    = true,
    round   = 4,
    outline = 1,
    scale   = 1,
    image   = { m1 = "", tp = "", crate = "" },
    imgTrans = 0.5,
    imgFit  = "Crop",
}

local IMG = { dir = "OJBS_Images" }

function IMG.available()
    return type(listfiles) == "function" and type(isfolder) == "function"
end

function IMG.ensure()
    if not (makefolder and isfolder) then return false end
    local ok = pcall(function()
        if not isfolder(IMG.dir) then makefolder(IMG.dir) end
    end)
    return ok
end

function IMG.files()
    local out = {}
    if not (listfiles and isfolder) then return out end
    local ok, files = pcall(listfiles, IMG.dir)
    if not ok or type(files) ~= "table" then return out end
    for _, f in ipairs(files) do
        if type(f) == "string" then
            local name = string.match(f, "([^/\\]+)$") or f
            local low = string.lower(name)
            if string.match(low, "%.png$") or string.match(low, "%.jpg$")
                or string.match(low, "%.jpeg$") or string.match(low, "%.webp$")
                or string.match(low, "%.bmp$") then
                out[#out + 1] = { path = f, name = name }
            end
        end
    end
    table.sort(out, function(a, b) return string.lower(a.name) < string.lower(b.name) end)
    return out
end

function IMG.resolve(src)
    if type(src) ~= "string" or src == "" then return nil end
    if string.find(src, "rbxassetid://", 1, true) or string.find(src, "rbxasset://", 1, true) then
        return src
    end
    if string.match(src, "^https?://") then return nil end
    local fn = getcustomasset or getsynasset
    if type(fn) ~= "function" then return nil end
    local ok, content = pcall(fn, src)
    if ok and type(content) == "string" and content ~= "" then return content end
    return nil
end

function IMG.import(url)
    if type(url) ~= "string" then return false, "no url" end
    url = string.gsub(url, "^%s+", "")
    url = string.gsub(url, "%s+$", "")
    if not string.match(url, "^https?://") then return false, "needs an http(s) link" end
    if not (writefile and game.HttpGet) then return false, "executor cannot download" end
    local clean = string.gsub(url, "[?#].*$", "")
    local name = string.match(clean, "([^/\\]+)$") or ""
    if not string.match(string.lower(name), "%.[a-z0-9]+$") then
        name = "img_" .. tostring(os.time()) .. ".png"
    end
    if not IMG.ensure() then return false, "cannot create " .. IMG.dir end
    local ok, body = pcall(game.HttpGet, game, url)
    if not ok or type(body) ~= "string" or body == "" then return false, "download failed" end
    local path = IMG.dir .. "/" .. name
    if not pcall(writefile, path, body) then return false, "write failed" end
    return true, path
end

pcall(IMG.ensure)

local MAX_TICK     = 800   -- dispatch ceiling per frame per slot
local MAX_INFLIGHT = 128   -- outstanding InvokeServer calls per slot

local BASE = {
    bg     = Color3.fromRGB(22, 25, 32),
    bg2    = Color3.fromRGB(27, 31, 39),
    panel  = Color3.fromRGB(35, 40, 50),
    panel2 = Color3.fromRGB(44, 50, 62),
    line   = Color3.fromRGB(56, 63, 77),
    text   = Color3.fromRGB(233, 237, 244),
    dim    = Color3.fromRGB(146, 156, 173),
    black  = Color3.fromRGB(0, 0, 0),
}

local THEMES = {
    m1    = { a = Color3.fromRGB(64, 152, 255), b = Color3.fromRGB(140, 216, 255) },
    tp    = { a = Color3.fromRGB(157, 100, 255), b = Color3.fromRGB(208, 168, 255) },
    crate = { a = Color3.fromRGB(78, 226, 198), b = Color3.fromRGB(168, 255, 238) },
}

local SWATCHES = {
    Color3.fromRGB(255, 138, 32), Color3.fromRGB(255, 198, 92),
    Color3.fromRGB(64, 152, 255), Color3.fromRGB(140, 216, 255),
    Color3.fromRGB(157, 100, 255), Color3.fromRGB(208, 168, 255),
    Color3.fromRGB(120, 235, 150), Color3.fromRGB(255, 102, 133),
}

local RED = Color3.fromRGB(255, 110, 110)

local State = {
    open = nil,
    railOpen = false,
    colors = {
        m1    = { a = THEMES.m1.a,    b = THEMES.m1.b },
        tp    = { a = THEMES.tp.a,    b = THEMES.tp.b },
        crate = { a = THEMES.crate.a, b = THEMES.crate.b },
    },
}

-- ---------------------------------------------------------------- helpers
local CONNS = {}
local function track(c) CONNS[#CONNS + 1] = c; return c end

local function inst(class, props, parent)
    local o = Instance.new(class)
    if props then
        for k, v in pairs(props) do
            if k ~= "Parent" then o[k] = v end
        end
    end
    if parent then o.Parent = parent end
    return o
end

local CORNERS, OUTLINES, HALOS = {}, {}, {}

local function corner(o, r)
    local px = math.min(r or 8, STYLE.round)
    local ui = inst("UICorner", { CornerRadius = UDim.new(0, px) }, o)
    CORNERS[#CORNERS + 1] = { ui = ui, r = r or 8 }
    return ui
end

local function outline(o, thick)
    local base = thick or 1.4
    local s = inst("UIStroke", {
        Color = BASE.black,
        Thickness = base * STYLE.outline,
        Transparency = 0,
        ApplyStrokeMode = Enum.ApplyStrokeMode.Border,
    }, o)
    OUTLINES[#OUTLINES + 1] = { s = s, base = base }
    return s
end

local function accentStroke(o, color, thick, trans)
    local base = thick or 1
    local s = inst("UIStroke", {
        Color = color,
        Thickness = base * STYLE.outline,
        Transparency = trans or 0,
        ApplyStrokeMode = Enum.ApplyStrokeMode.Border,
    }, o)
    OUTLINES[#OUTLINES + 1] = { s = s, base = base }
    return s
end

local function pad(o, l, t, r, b)
    inst("UIPadding", {
        PaddingLeft   = UDim.new(0, l or 0),
        PaddingTop    = UDim.new(0, t or 0),
        PaddingRight  = UDim.new(0, r or 0),
        PaddingBottom = UDim.new(0, b or 0),
    }, o)
end

local function tw(o, t, props, style, dir)
    local tr = TweenService:Create(o, TweenInfo.new((t or 0.18) * MOTION, style or Enum.EasingStyle.Quad, dir or Enum.EasingDirection.Out), props)
    tr:Play()
    return tr
end

local function gradient(o, a, b, rot)
    return inst("UIGradient", { Rotation = rot or 0, Color = ColorSequence.new(a, b) }, o)
end

-- centred by construction: anchor 0.5/0.5 + 0.5/0.5 position, so a halo can never
-- sit off-centre relative to its widget no matter what size the caller sets
local function halo(parent, color, radius, alpha)
    local g = inst("Frame", {
        AnchorPoint = Vector2.new(0.5, 0.5),
        Position = UDim2.fromScale(0.5, 0.5),
        Size = UDim2.fromScale(1, 1),
        BackgroundColor3 = color,
        BackgroundTransparency = alpha or 0.85,
        BorderSizePixel = 0,
        Active = false,
    }, parent)
    inst("UICorner", { CornerRadius = UDim.new(0, radius or 8) }, g)
    HALOS[#HALOS + 1] = g
    return g
end

local function nextOrder(page)
    local n = (page:GetAttribute("order") or 0) + 1
    page:SetAttribute("order", n)
    return n
end

local function rootOf(m)
    if not m then return nil end
    return m:FindFirstChild("HumanoidRootPart") or m:FindFirstChild("RootPart")
end

local function playersFolder()
    local c = Workspace:FindFirstChild("Characters")
    local s = c and c:FindFirstChild("Server")
    return s and s:FindFirstChild("Players")
end

local function npcsFolder()
    local c = Workspace:FindFirstChild("Characters")
    local s = c and c:FindFirstChild("Server")
    return s and s:FindFirstChild("NPCs")
end

-- ---------------------------------------------------------------- backgrounds
local applyBackground, applyScan

do
    local function bgAlpha()
        return math.clamp(0.92 - 0.42 * STYLE.opacity, 0.12, 0.97)
    end

    local function clearLayer(layer)
        if not layer then return end
        for _, c in ipairs(layer:GetChildren()) do c:Destroy() end
    end

    local function buildStuds(layer)
        local pitch, size = 36, 22
        local alpha = bgAlpha()
        local base = Color3.fromRGB(52, 60, 76)
        local lit  = Color3.fromRGB(92, 104, 126)
        local rows = math.ceil(WINDOW_H / pitch)
        local cols = math.ceil(WINDOW_W / pitch) + 1
        for r = 0, rows - 1 do
            local shift = (r % 2 == 1) and pitch * 0.5 or 0
            for c = 0, cols - 1 do
                local s = inst("Frame", {
                    Position = UDim2.fromOffset(c * pitch + shift, r * pitch),
                    Size = UDim2.fromOffset(size, size),
                    BackgroundColor3 = base,
                    BackgroundTransparency = alpha,
                    BorderSizePixel = 0,
                    Active = false,
                }, layer)
                inst("UICorner", { CornerRadius = UDim.new(0, size / 2) }, s)
                inst("UIGradient", { Rotation = 45, Color = ColorSequence.new(lit, base) }, s)
                local dot = inst("Frame", {
                    Position = UDim2.fromOffset(5, 4),
                    Size = UDim2.fromOffset(size * 0.34, size * 0.34),
                    BackgroundColor3 = Color3.new(1, 1, 1),
                    BackgroundTransparency = math.clamp(alpha + 0.14, 0, 1),
                    BorderSizePixel = 0,
                    Active = false,
                }, s)
                inst("UICorner", { CornerRadius = UDim.new(0, size / 4) }, dot)
            end
        end
    end

    local function buildGrid(layer)
        local step = 32
        local alpha = math.clamp(bgAlpha() + 0.1, 0.3, 0.99)
        local col = Color3.fromRGB(124, 144, 176)
        for x = step, WINDOW_W, step do
            inst("Frame", {
                Position = UDim2.fromOffset(x, 0), Size = UDim2.new(0, 1, 1, 0),
                BackgroundColor3 = col, BackgroundTransparency = alpha, BorderSizePixel = 0, Active = false,
            }, layer)
        end
        for y = step, WINDOW_H, step do
            inst("Frame", {
                Position = UDim2.fromOffset(0, y), Size = UDim2.new(1, 0, 0, 1),
                BackgroundColor3 = col, BackgroundTransparency = alpha, BorderSizePixel = 0, Active = false,
            }, layer)
        end
    end

    -- NumberSequence caps at 20 keypoints, so the stripes are drawn as frames
    local function scanFrame(parent, baseAlpha)
        local holder = inst("Frame", {
            Size = UDim2.fromScale(1, 1),
            BackgroundTransparency = 1,
            BorderSizePixel = 0,
            Active = false,
        }, parent)
        local trans = math.clamp(baseAlpha, 0.5, 0.99)
        for y = 0, WINDOW_H - 1, 4 do
            inst("Frame", {
                Position = UDim2.fromOffset(0, y),
                Size = UDim2.new(1, 0, 0, 1),
                BackgroundColor3 = Color3.new(0, 0, 0),
                BackgroundTransparency = trans,
                BorderSizePixel = 0,
                Active = false,
            }, holder)
        end
        return holder
    end

    local function buildCRT(layer)
        scanFrame(layer, math.clamp(0.99 - 0.55 * STYLE.opacity, 0.7, 0.99))
        local vig = inst("Frame", {
            Size = UDim2.fromScale(1, 1),
            BackgroundColor3 = Color3.new(0, 0, 0),
            BorderSizePixel = 0,
            Active = false,
        }, layer)
        inst("UIGradient", {
            Rotation = 90,
            Color = ColorSequence.new(Color3.new(0, 0, 0)),
            Transparency = NumberSequence.new({ 0.55, 1, 0.55 }),
        }, vig)
    end

    local function buildImage(layer, src)
        local content = IMG.resolve(src)
        if not content then return false end
        local fit = Enum.ScaleType.Crop
        if STYLE.imgFit == "Stretch" then fit = Enum.ScaleType.Stretch
        elseif STYLE.imgFit == "Fit" then fit = Enum.ScaleType.Fit end
        inst("ImageLabel", {
            Size = UDim2.fromScale(1, 1),
            BackgroundTransparency = 1,
            BorderSizePixel = 0,
            Image = content,
            ImageTransparency = math.clamp(STYLE.imgTrans, 0, 1),
            ScaleType = fit,
            Active = false,
        }, layer)
        return true
    end

    applyBackground = function(win, kind)
        local layer = win.bgLayer
        if not (layer and layer.Parent) then return end
        kind = kind or "classic"
        local src = STYLE.image[win.key] or ""
        local sig = kind .. "@" .. string.format("%.3f", STYLE.opacity) .. "|" .. src
            .. "|" .. string.format("%.2f", STYLE.imgTrans) .. "|" .. tostring(STYLE.imgFit)
        if win.bgSig == sig then return end
        win.bgSig = sig
        win.bgKind = kind
        clearLayer(layer)
        if kind == "studs" then buildStuds(layer)
        elseif kind == "grid" then buildGrid(layer)
        elseif kind == "crt" then buildCRT(layer) end
        if src ~= "" then buildImage(layer, src) end
    end

    applyScan = function(win, on)
        local layer = win.scanLayer
        if not (layer and layer.Parent) then return end
        local sig = on and "on" or "off"
        if win.scanSig == sig then return end
        win.scanSig = sig
        clearLayer(layer)
        if on then scanFrame(layer, 0.94) end
    end
end


-- ---------------------------------------------------------------- root gui
local gui = inst("ScreenGui", {
    Name = "OJBS",
    ResetOnSpawn = false,
    IgnoreGuiInset = true,
    DisplayOrder = 500,
    ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
})
do
    local ok, hui = pcall(gethui)
    if ok and hui then gui.Parent = hui else gui.Parent = LP:WaitForChild("PlayerGui") end
end

local WIN_CLASS = "CanvasGroup"
do
    local ok = pcall(function() local c = Instance.new("CanvasGroup"); c:Destroy() end)
    if not ok then WIN_CLASS = "Frame" end
end

-- ---------------------------------------------------------------- toast
local toast = inst("Frame", {
    AnchorPoint = Vector2.new(0.5, 1),
    Position = UDim2.new(0.5, 0, 1, -24),
    Size = UDim2.fromOffset(340, 40),
    BackgroundColor3 = BASE.panel,
    BackgroundTransparency = 1,
    BorderSizePixel = 0,
    Active = false,
    Visible = false,
}, gui)
corner(toast, 10)
local toastEdge = outline(toast, 1.4)
toastEdge.Transparency = 1
local toastStroke = accentStroke(toast, THEMES.m1.a, 1, 1)
local toastLabel = inst("TextLabel", {
    BackgroundTransparency = 1,
    Size = UDim2.fromScale(1, 1),
    Font = FONT_MONO,
    TextSize = 12,
    TextColor3 = BASE.text,
    TextTransparency = 1,
    Text = "",
}, toast)

local toastToken = 0
local function notify(text, color)
    toastToken += 1
    local t = toastToken
    toastLabel.Text = text
    toastLabel.TextColor3 = color or BASE.text
    toastStroke.Color = color or BASE.text
    toast.Visible = true
    tw(toast, 0.15, { BackgroundTransparency = 0.12 })
    tw(toastEdge, 0.15, { Transparency = 0 })
    tw(toastStroke, 0.15, { Transparency = 0 })
    tw(toastLabel, 0.15, { TextTransparency = 0 })
    task.delay(1.8, function()
        if toastToken ~= t or not toast.Parent then return end
        tw(toast, 0.3, { BackgroundTransparency = 1 })
        tw(toastEdge, 0.3, { Transparency = 1 })
        tw(toastStroke, 0.3, { Transparency = 1 })
        tw(toastLabel, 0.3, { TextTransparency = 1 })
        task.delay(0.32, function()
            if toastToken == t and toast.Parent then toast.Visible = false end
        end)
    end)
end

-- ---------------------------------------------------------------- persistence
local CONFIG_FILE = "OJBS_UI_" .. tostring(game.PlaceId) .. ".json"

local function writeThemes()
    local ok, err = pcall(function()
        if not writefile then error("no file api") end
        local out = {}
        for k, v in pairs(State.colors) do
            out[k] = { math.round(v.a.R * 255), math.round(v.a.G * 255), math.round(v.a.B * 255) }
        end
        out.settings = {
            bg      = STYLE.bg,
            opacity = STYLE.opacity,
            scan    = STYLE.scan,
            glow    = STYLE.glow,
            round   = STYLE.round,
            outline = STYLE.outline,
            scale   = STYLE.scale,
            image   = STYLE.image,
            imgTrans = STYLE.imgTrans,
            imgFit  = STYLE.imgFit,
        }
        writefile(CONFIG_FILE, HttpService:JSONEncode(out))
    end)
    return ok, err
end

local saveToken = 0
local function saveThemes(deferred)
    saveToken += 1
    if not deferred then return writeThemes() end
    local t = saveToken
    task.delay(0.7, function()
        if t == saveToken then writeThemes() end
    end)
end

local function loadThemes()
    local ok, data = pcall(function()
        if not (isfile and isfile(CONFIG_FILE)) then return nil end
        return HttpService:JSONDecode(readfile(CONFIG_FILE))
    end)
    if not ok or type(data) ~= "table" then return end
    for k, v in pairs(data) do
        if State.colors[k] and type(v) == "table" and v[1] then
            local c = Color3.fromRGB(v[1], v[2], v[3])
            State.colors[k].a = c
            State.colors[k].b = c:Lerp(Color3.new(1, 1, 1), 0.35)
        end
    end
    local s = data.settings
    if type(s) ~= "table" then return end
    if type(s.bg) == "table" then
        for k, v in pairs(s.bg) do
            if STYLE.bg[k] and type(v) == "string" then STYLE.bg[k] = v end
        end
    end
    STYLE.opacity = math.clamp(tonumber(s.opacity) or STYLE.opacity, 0, 1)
    STYLE.glow    = s.glow ~= false
    STYLE.scan    = s.scan ~= false
    STYLE.round   = math.clamp(tonumber(s.round) or STYLE.round, 0, 14)
    STYLE.outline = math.clamp(tonumber(s.outline) or STYLE.outline, 0.3, 3)
    STYLE.scale   = math.clamp(tonumber(s.scale) or STYLE.scale, 0.7, 1.6)
    if type(s.image) == "table" then
        for k, v in pairs(s.image) do
            if STYLE.image[k] ~= nil and type(v) == "string" then STYLE.image[k] = v end
        end
    end
    STYLE.imgTrans = math.clamp(tonumber(s.imgTrans) or STYLE.imgTrans, 0, 1)
    if s.imgFit == "Crop" or s.imgFit == "Stretch" or s.imgFit == "Fit" then STYLE.imgFit = s.imgFit end
end
loadThemes()

-- ---------------------------------------------------------------- windows
local WINDOWS = {}
local TAB_HOOKS = {}

local MODULE_ORDER = { "m1", "tp", "crate" }

local function moduleOffset(key)
    for i, k in ipairs(MODULE_ORDER) do
        if k == key then return (i - (#MODULE_ORDER + 1) * 0.5) * 70 end
    end
    return 0
end

local function windowOpen(win, key)
    local vp = Workspace.CurrentCamera.ViewportSize
    local off = moduleOffset(key)
    local cy = math.clamp(vp.Y * 0.5 + off, WINDOW_H * 0.5 + 14, vp.Y - WINDOW_H * 0.5 - 14)
    local x = vp.X - RAIL_OFF - RAIL_W - 16 - WINDOW_W
    if x < 12 then x = 12 end
    local y = cy - WINDOW_H * 0.5

    win.frame.Visible = true
    win.frame.Position = UDim2.fromOffset(x + 56, y)
    if win.frame:IsA("CanvasGroup") then win.frame.GroupTransparency = 1 end
    if win.scale then
        win.scale.Scale = STYLE.scale * 0.985
        tw(win.scale, 0.34, { Scale = STYLE.scale }, Enum.EasingStyle.Quint)
    end
    win.tweenIn = tw(win.frame, 0.34, { Position = UDim2.fromOffset(x, y) }, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
    if win.frame:IsA("CanvasGroup") then tw(win.frame, 0.26, { GroupTransparency = 0 }) end
end

local function windowClose(win)
    if not win.frame.Visible then return end
    if win.tweenIn then win.tweenIn:Cancel(); win.tweenIn = nil end
    local p = win.frame.Position
    tw(win.frame, 0.18, { Position = UDim2.new(p.X.Scale, p.X.Offset + 24, p.Y.Scale, p.Y.Offset) }, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
    if win.frame:IsA("CanvasGroup") then
        local t = tw(win.frame, 0.16, { GroupTransparency = 1 }, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
        t.Completed:Connect(function()
            if State.open ~= win.key then win.frame.Visible = false end
        end)
    else
        win.frame.Visible = false
    end
end

local function closeActive()
    if State.open and WINDOWS[State.open] then windowClose(WINDOWS[State.open]) end
    State.open = nil
end

local function openWindow(key)
    if State.open == key then return end
    if State.open and WINDOWS[State.open] then windowClose(WINDOWS[State.open]) end
    State.open = key
    windowOpen(WINDOWS[key], key)
end

local function makeWindow(key, title, icon)
    local win = { key = key, onAccent = {}, pages = {} }

    local frame = inst(WIN_CLASS, {
        Position = UDim2.fromOffset(-3000, 0),
        Size = UDim2.fromOffset(WINDOW_W, WINDOW_H),
        BackgroundColor3 = BASE.bg,
        BorderSizePixel = 0,
        ClipsDescendants = true,
        Visible = false,
    }, gui)
    corner(frame, 12)
    outline(frame, 2)
    win.frame = frame
    win.scale = inst("UIScale", { Scale = STYLE.scale }, frame)

    local bgLayer = inst("Frame", {
        Size = UDim2.fromScale(1, 1),
        BackgroundTransparency = 1,
        BorderSizePixel = 0,
        Active = false,
    }, frame)
    win.bgLayer = bgLayer

    local topHalo = inst("Frame", {
        Position = UDim2.fromOffset(0, -4),
        Size = UDim2.new(1, 0, 0, 14),
        BackgroundColor3 = State.colors[key].a,
        BackgroundTransparency = 0.72,
        BorderSizePixel = 0,
    }, frame)
    local topBar = inst("Frame", { Size = UDim2.new(1, 0, 0, 3), BackgroundColor3 = Color3.new(1, 1, 1), BorderSizePixel = 0 }, frame)
    local topGrad = gradient(topBar, State.colors[key].a, State.colors[key].b, 0)

    local header = inst("Frame", { Size = UDim2.fromOffset(WINDOW_W, 46), BackgroundTransparency = 1 }, frame)
    local dragArea = inst("Frame", { Size = UDim2.new(1, -56, 1, 0), BackgroundTransparency = 1 }, header)
    local iconLbl = inst("TextLabel", {
        BackgroundTransparency = 1,
        Position = UDim2.fromOffset(16, 0),
        Size = UDim2.fromOffset(28, 46),
        Font = FONT_MONO,
        TextSize = 19,
        TextColor3 = State.colors[key].a,
        Text = icon,
    }, header)
    inst("TextLabel", {
        BackgroundTransparency = 1,
        Position = UDim2.fromOffset(46, 0),
        Size = UDim2.new(1, -120, 1, 0),
        Font = FONT_TITLE,
        TextSize = 17,
        TextColor3 = BASE.text,
        TextXAlignment = Enum.TextXAlignment.Left,
        Text = title,
    }, header)

    local closeBtn = inst("TextButton", {
        AnchorPoint = Vector2.new(1, 0.5),
        Position = UDim2.new(1, -12, 0, 23),
        Size = UDim2.fromOffset(28, 28),
        BackgroundColor3 = BASE.panel,
        Text = "✕",
        Font = FONT_MONO,
        TextSize = 13,
        TextColor3 = BASE.dim,
        AutoButtonColor = false,
    }, header)
    corner(closeBtn, 8)
    outline(closeBtn, 1.2)
    closeBtn.MouseButton1Click:Connect(function() closeActive() end)
    closeBtn.MouseEnter:Connect(function() closeBtn.TextColor3 = RED end)
    closeBtn.MouseLeave:Connect(function() closeBtn.TextColor3 = BASE.dim end)

    local tabBar = inst("ScrollingFrame", {
        Position = UDim2.fromOffset(14, 50),
        Size = UDim2.new(1, -28, 0, 30),
        BackgroundTransparency = 1,
        BorderSizePixel = 0,
        ScrollBarThickness = 0,
        CanvasSize = UDim2.new(0, 0, 0, 0),
        AutomaticCanvasSize = Enum.AutomaticSize.X,
        ScrollingDirection = Enum.ScrollingDirection.X,
        ClipsDescendants = true,
    }, frame)
    inst("UIListLayout", {
        FillDirection = Enum.FillDirection.Horizontal,
        Padding = UDim.new(0, 4),
        SortOrder = Enum.SortOrder.LayoutOrder,
        VerticalAlignment = Enum.VerticalAlignment.Center,
    }, tabBar)

    local function tabMaxScroll()
        local viewW = tabBar.AbsoluteSize.X
        local canvasW = tabBar.AbsoluteCanvasSize.X
        if canvasW <= 0 then canvasW = tabBar.CanvasSize.X.Offset end
        return math.max(canvasW - viewW, 0)
    end

    track(UIS.InputChanged:Connect(function(input)
        if input.UserInputType ~= Enum.UserInputType.MouseWheel then return end
        if not frame.Visible then return end
        local maxX = tabMaxScroll()
        if maxX <= 0 then return end
        local ap, as = tabBar.AbsolutePosition, tabBar.AbsoluteSize
        local m = UIS:GetMouseLocation()
        if m.X < ap.X or m.X > ap.X + as.X or m.Y < ap.Y - 2 or m.Y > ap.Y + as.Y + 2 then return end
        local x = math.clamp(tabBar.CanvasPosition.X - input.Position.Z * 52, 0, maxX)
        tabBar.CanvasPosition = Vector2.new(x, 0)
    end))

    local body = inst("Frame", {
        Position = UDim2.fromOffset(0, 84),
        Size = UDim2.new(1, 0, 1, -114),
        BackgroundTransparency = 1,
        ClipsDescendants = true,
    }, frame)

    local footer = inst("Frame", { Position = UDim2.new(0, 0, 1, -30), Size = UDim2.new(1, 0, 0, 30), BackgroundTransparency = 1 }, frame)
    win.footer = footer
    local statusDot = inst("Frame", {
        AnchorPoint = Vector2.new(0, 0.5),
        Position = UDim2.new(0, 16, 0.5, 0),
        Size = UDim2.fromOffset(6, 6),
        BackgroundColor3 = State.colors[key].a,
        BorderSizePixel = 0,
    }, footer)
    corner(statusDot, 3)
    local statusLbl = inst("TextLabel", {
        BackgroundTransparency = 1,
        Position = UDim2.fromOffset(28, 0),
        Size = UDim2.new(1, -104, 1, 0),
        Font = FONT_MONO,
        TextSize = 11,
        TextColor3 = BASE.dim,
        TextXAlignment = Enum.TextXAlignment.Left,
        Text = "ready",
    }, footer)

    function win:status(text)
        statusLbl.Text = text
        statusLbl.TextColor3 = BASE.text
        task.delay(2.4, function()
            if statusLbl.Parent and statusLbl.Text == text then statusLbl.TextColor3 = BASE.dim end
        end)
    end

    function win:addTab(name)
        local idx = #self.pages + 1
        local btn = inst("TextButton", {
            Size = UDim2.fromOffset(TAB_W, 30),
            BackgroundTransparency = 1,
            Text = name,
            Font = FONT_MONO,
            TextSize = 12,
            TextColor3 = BASE.dim,
            TextTruncate = Enum.TextTruncate.AtEnd,
            TextXAlignment = Enum.TextXAlignment.Center,
            AutoButtonColor = false,
            LayoutOrder = idx,
        }, tabBar)
        local underline = inst("Frame", {
            AnchorPoint = Vector2.new(0, 1),
            Position = UDim2.new(0, 0, 1, 0),
            Size = UDim2.new(1, 0, 0, 2),
            BackgroundColor3 = Color3.new(1, 1, 1),
            BorderSizePixel = 0,
            Visible = false,
        }, btn)
        local ug = gradient(underline, State.colors[self.key].a, State.colors[self.key].b, 0)

        local holder = inst(WIN_CLASS, {
            Size = UDim2.fromScale(1, 1),
            BackgroundTransparency = 1,
            BorderSizePixel = 0,
            ClipsDescendants = true,
            Visible = false,
        }, body)

        local page = inst("ScrollingFrame", {
            Size = UDim2.fromScale(1, 1),
            BackgroundTransparency = 1,
            BorderSizePixel = 0,
            ScrollBarThickness = 3,
            ScrollBarImageColor3 = BASE.line,
            AutomaticCanvasSize = Enum.AutomaticSize.Y,
            CanvasSize = UDim2.new(0, 0, 0, 0),
            ScrollingDirection = Enum.ScrollingDirection.Y,
            Visible = true,
        }, holder)
        pad(page, 12, 4, 12, 12)
        inst("UIListLayout", { Padding = UDim.new(0, 8), SortOrder = Enum.SortOrder.LayoutOrder }, page)

        self.pages[idx] = { btn = btn, page = page, holder = holder, underline = underline, ugrad = ug }
        btn.MouseButton1Click:Connect(function() self:selectTab(idx) end)
        btn.MouseEnter:Connect(function()
            if self.activeTab ~= idx then tw(btn, 0.12, { TextColor3 = BASE.text }) end
        end)
        btn.MouseLeave:Connect(function()
            if self.activeTab ~= idx then tw(btn, 0.14, { TextColor3 = BASE.dim }) end
        end)
        if idx == 1 then self:selectTab(1) end
        return page
    end

    function win:selectTab(idx)
        if self.activeTab == idx then return end
        self.activeTab = idx
        for _, f in ipairs(TAB_HOOKS) do pcall(f, self.key, idx) end
        for i, t in ipairs(self.pages) do
            local on = (i == idx)
            t.btn.TextColor3 = on and State.colors[self.key].a or BASE.dim
            t.underline.Visible = on
            if on then
                t.holder.Visible = true
                t.page.Visible = true
                if t.holder:IsA("CanvasGroup") then
                    t.holder.GroupTransparency = 1
                    tw(t.holder, 0.16, { GroupTransparency = 0 }, Enum.EasingStyle.Quad)
                end
                t.holder.Position = UDim2.fromOffset(0, 6)
                tw(t.holder, 0.24, { Position = UDim2.fromOffset(0, 0) }, Enum.EasingStyle.Quint)
            elseif t.holder.Visible then
                if t.holder:IsA("CanvasGroup") then
                    local h = t.holder
                    local tr = tw(h, 0.1, { GroupTransparency = 1 }, Enum.EasingStyle.Quad)
                    tr.Completed:Connect(function()
                        if self.activeTab ~= i then
                            h.Visible = false
                            t.page.Visible = false
                        end
                    end)
                else
                    t.holder.Visible = false
                    t.page.Visible = false
                end
            end
        end
        task.defer(function()
            local t = self.pages[idx]
            if not t or not t.btn.Parent then return end
            local maxX = tabMaxScroll()
            if maxX <= 0 then return end
            local viewW = tabBar.AbsoluteSize.X
            local cur = tabBar.CanvasPosition.X
            local x = t.btn.AbsolutePosition.X - tabBar.AbsolutePosition.X + cur
            local w = t.btn.AbsoluteSize.X
            local target = cur
            if x - 8 < cur then
                target = x - 8
            elseif x + w + 8 > cur + viewW then
                target = x + w + 8 - viewW
            end
            target = math.clamp(target, 0, maxX)
            if math.abs(target - cur) > 0.5 then
                tw(tabBar, 0.2, { CanvasPosition = Vector2.new(target, 0) }, Enum.EasingStyle.Quint)
            end
        end)
    end

    function win:refreshAccent()
        local a = State.colors[self.key].a
        local b = State.colors[self.key].b
        for _, fn in ipairs(self.onAccent) do pcall(fn, a) end
        topGrad.Color = ColorSequence.new(a, b)
        topHalo.BackgroundColor3 = a
        iconLbl.TextColor3 = a
        statusDot.BackgroundColor3 = a
        for _, t in ipairs(self.pages) do
            t.ugrad.Color = ColorSequence.new(a, b)
        end
    end

    -- delta drag: the offset between cursor and window is captured once, then only
    -- the movement delta is applied, so the window cannot snap on the initial click
    local dragging, dragTouch = false, false
    local dragStartMouse, dragStartPos = Vector2.new(), Vector2.new()
    dragArea.InputBegan:Connect(function(input)
        if input.UserInputType ~= Enum.UserInputType.MouseButton1 and input.UserInputType ~= Enum.UserInputType.Touch then return end
        if win.tweenIn then pcall(function() win.tweenIn:Cancel() end); win.tweenIn = nil end
        dragging = true
        dragTouch = (input.UserInputType == Enum.UserInputType.Touch)
        dragStartMouse = dragTouch and input.Position or UIS:GetMouseLocation()
        dragStartPos = Vector2.new(frame.AbsolutePosition.X, frame.AbsolutePosition.Y)
    end)
    track(UIS.InputChanged:Connect(function(input)
        if not dragging then return end
        if input.UserInputType ~= Enum.UserInputType.MouseMovement and input.UserInputType ~= Enum.UserInputType.Touch then return end
        local m = (dragTouch and input.UserInputType == Enum.UserInputType.Touch) and input.Position or UIS:GetMouseLocation()
        local sc = win.scale and win.scale.Scale or 1
        local dx = (m.X - dragStartMouse.X) / sc
        local dy = (m.Y - dragStartMouse.Y) / sc
        local vp = Workspace.CurrentCamera.ViewportSize
        frame.Position = UDim2.fromOffset(
            math.clamp(dragStartPos.X + dx, -(WINDOW_W - 180), vp.X - 180),
            math.clamp(dragStartPos.Y + dy, -6, vp.Y - 50)
        )
    end))
    track(UIS.InputEnded:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            dragging = false
        end
    end))

    local scanLayer = inst("Frame", {
        Size = UDim2.fromScale(1, 1),
        BackgroundTransparency = 1,
        BorderSizePixel = 0,
        Active = false,
    }, frame)
    win.scanLayer = scanLayer

    pcall(applyBackground, win, STYLE.bg[key] or "classic")
    pcall(applyScan, win, STYLE.scan)

    WINDOWS[key] = win
    return win
end

-- ---------------------------------------------------------------- widgets
local W = {}
local RGB = {}

function W.section(win, page, text)
    local f = inst("Frame", { Size = UDim2.new(1, 0, 0, 20), BackgroundTransparency = 1, LayoutOrder = nextOrder(page) }, page)
    local l = inst("TextLabel", {
        BackgroundTransparency = 1,
        Size = UDim2.fromScale(1, 1),
        Font = FONT_MONO,
        TextSize = 11,
        TextColor3 = State.colors[win.key].a,
        TextXAlignment = Enum.TextXAlignment.Left,
        Text = string.upper(text),
    }, f)
    table.insert(win.onAccent, function(a) l.TextColor3 = a end)
    return f
end

function W.note(win, page, text)
    local row = inst("Frame", {
        Size = UDim2.new(1, 0, 0, 0),
        AutomaticSize = Enum.AutomaticSize.Y,
        BackgroundColor3 = BASE.panel,
        BackgroundTransparency = 0.5,
        BorderSizePixel = 0,
        LayoutOrder = nextOrder(page),
    }, page)
    corner(row, 8)
    outline(row, 1.1)
    pad(row, 12, 10, 12, 10)
    inst("TextLabel", {
        BackgroundTransparency = 1,
        Size = UDim2.new(1, 0, 0, 0),
        AutomaticSize = Enum.AutomaticSize.Y,
        Font = FONT_MONO,
        TextSize = 12,
        TextColor3 = BASE.text,
        TextXAlignment = Enum.TextXAlignment.Left,
        TextYAlignment = Enum.TextYAlignment.Top,
        TextWrapped = true,
        LineHeight = 1.22,
        Text = text,
    }, row)
    return row
end

function W.toggle(win, page, opts)
    local row = inst("Frame", {
        Size = UDim2.new(1, 0, 0, 36),
        BackgroundColor3 = BASE.panel,
        BackgroundTransparency = 0.25,
        BorderSizePixel = 0,
        LayoutOrder = nextOrder(page),
    }, page)
    corner(row, 8)
    outline(row, 1.2)
    inst("TextLabel", {
        BackgroundTransparency = 1,
        Position = UDim2.fromOffset(12, 0),
        Size = UDim2.new(1, -80, 1, 0),
        Font = FONT_MONO,
        TextSize = 13,
        TextColor3 = BASE.text,
        TextXAlignment = Enum.TextXAlignment.Left,
        Text = opts.text,
    }, row)

    local pillHalo = halo(row, State.colors[win.key].a, 12, 0.9)
    pillHalo.Position = UDim2.new(1, -31, 0.5, 0)
    pillHalo.Size = UDim2.fromOffset(52, 34)

    local pill = inst("Frame", {
        AnchorPoint = Vector2.new(1, 0.5),
        Position = UDim2.new(1, -12, 0.5, 0),
        Size = UDim2.fromOffset(38, 20),
        BackgroundColor3 = BASE.line,
        BorderSizePixel = 0,
    }, row)
    corner(pill, 10)
    outline(pill, 1.2)
    local pillGrad = gradient(pill, State.colors[win.key].a, State.colors[win.key].b, 90)

    local knob = inst("Frame", {
        AnchorPoint = Vector2.new(0, 0.5),
        Position = UDim2.new(0, 2, 0.5, 0),
        Size = UDim2.fromOffset(16, 16),
        BackgroundColor3 = Color3.fromRGB(238, 241, 247),
        BorderSizePixel = 0,
    }, pill)
    corner(knob, 8)
    outline(knob, 1)

    local value = opts.value and true or false
    local function render(animate)
        pill.BackgroundTransparency = value and 0 or 0.75
        pill.BackgroundColor3 = value and Color3.new(1, 1, 1) or BASE.line
        pillGrad.Enabled = value
        pillHalo.Visible = value and STYLE.glow
        local pos = value and UDim2.new(0, 20, 0.5, 0) or UDim2.new(0, 2, 0.5, 0)
        if animate then
            tw(knob, 0.16, { Position = pos }, Enum.EasingStyle.Quint)
        else
            knob.Position = pos
        end
    end
    render(false)
    table.insert(win.onAccent, function()
        pillGrad.Color = ColorSequence.new(State.colors[win.key].a, State.colors[win.key].b)
        pillHalo.BackgroundColor3 = State.colors[win.key].a
    end)

    local hit = inst("TextButton", { BackgroundTransparency = 1, Text = "", Size = UDim2.fromScale(1, 1) }, row)
    hit.MouseButton1Click:Connect(function()
        value = not value
        render(true)
        if opts.callback then opts.callback(value) end
    end)
    return { frame = row, get = function() return value end, set = function(v) value = v; render(true) end }
end

W.dragState = nil

function W.slider(win, page, opts)
    local row = inst("Frame", {
        Size = UDim2.new(1, 0, 0, 50),
        BackgroundColor3 = BASE.panel,
        BackgroundTransparency = 0.25,
        BorderSizePixel = 0,
        LayoutOrder = nextOrder(page),
    }, page)
    corner(row, 8)
    outline(row, 1.2)
    inst("TextLabel", {
        BackgroundTransparency = 1,
        Position = UDim2.fromOffset(12, 6),
        Size = UDim2.new(1, -100, 0, 16),
        Font = FONT_MONO,
        TextSize = 13,
        TextColor3 = BASE.text,
        TextXAlignment = Enum.TextXAlignment.Left,
        Text = opts.text,
    }, row)
    local valLbl = inst("TextLabel", {
        BackgroundTransparency = 1,
        AnchorPoint = Vector2.new(1, 0),
        Position = UDim2.new(1, -12, 0, 6),
        Size = UDim2.fromOffset(90, 16),
        Font = FONT_MONO,
        TextSize = 12,
        TextColor3 = State.colors[win.key].a,
        TextXAlignment = Enum.TextXAlignment.Right,
        Text = "",
    }, row)

    local trackHalo = halo(row, State.colors[win.key].a, 6, 0.9)
    trackHalo.Position = UDim2.new(0.5, 0, 0, 36)
    trackHalo.Size = UDim2.new(1, -16, 0, 14)

    local bar = inst("Frame", {
        Position = UDim2.fromOffset(12, 34),
        Size = UDim2.new(1, -24, 0, 4),
        BackgroundColor3 = BASE.line,
        BorderSizePixel = 0,
    }, row)
    corner(bar, 2)

    local fill = inst("Frame", { Size = UDim2.fromScale(0, 1), BackgroundColor3 = Color3.new(1, 1, 1), BorderSizePixel = 0 }, bar)
    corner(fill, 2)
    local fillGrad = gradient(fill, State.colors[win.key].a, State.colors[win.key].b, 0)

    local knob = inst("Frame", {
        AnchorPoint = Vector2.new(0.5, 0.5),
        Position = UDim2.new(0, 0, 0.5, 0),
        Size = UDim2.fromOffset(12, 12),
        BackgroundColor3 = Color3.fromRGB(240, 243, 248),
        BorderSizePixel = 0,
    }, bar)
    corner(knob, 6)
    outline(knob, 1)

    local min, max = opts.min, opts.max
    local step = opts.step or 1
    local value = opts.value or min

    local function quant(raw)
        if step <= 0 then return raw end
        return min + math.floor((raw - min) / step + 0.5) * step
    end
    local function fmt(v)
        if step < 1 then return string.format("%.2f", v) end
        return tostring(math.floor(v + 0.5))
    end
    local function apply(v, fire)
        value = math.clamp(quant(v), min, max)
        local pct = (value - min) / math.max(max - min, 0.0001)
        fill.Size = UDim2.new(pct, 0, 1, 0)
        knob.Position = UDim2.new(pct, 0, 0.5, 0)
        valLbl.Text = fmt(value) .. (opts.suffix or "")
        if fire and opts.callback then opts.callback(value) end
    end

    table.insert(win.onAccent, function()
        valLbl.TextColor3 = State.colors[win.key].a
        trackHalo.BackgroundColor3 = State.colors[win.key].a
        fillGrad.Color = ColorSequence.new(State.colors[win.key].a, State.colors[win.key].b)
    end)

    local hit = inst("TextButton", {
        BackgroundTransparency = 1,
        Text = "",
        Position = UDim2.fromOffset(0, 24),
        Size = UDim2.new(1, 0, 0, 24),
    }, row)
    hit.InputBegan:Connect(function(input)
        if input.UserInputType ~= Enum.UserInputType.MouseButton1 and input.UserInputType ~= Enum.UserInputType.Touch then return end
        tw(knob, 0.1, { Size = UDim2.fromOffset(14, 14) }, Enum.EasingStyle.Quint)
        local function update(px)
            local w = math.max(bar.AbsoluteSize.X, 1)
            local pct = math.clamp((px - bar.AbsolutePosition.X) / w, 0, 1)
            apply(min + pct * (max - min), true)
        end
        update(input.Position.X)
        W.dragState = update
    end)
    track(UIS.InputEnded:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            if knob.Parent then tw(knob, 0.14, { Size = UDim2.fromOffset(12, 12) }, Enum.EasingStyle.Quint) end
        end
    end))

    apply(value, false)
    return { get = function() return value end, set = function(v) apply(v, true) end }
end

function W.input(win, page, opts)
    local row = inst("Frame", {
        Size = UDim2.new(1, 0, 0, 40),
        BackgroundColor3 = BASE.panel,
        BackgroundTransparency = 0.25,
        BorderSizePixel = 0,
        LayoutOrder = nextOrder(page),
    }, page)
    corner(row, 8)
    outline(row, 1.2)
    inst("TextLabel", {
        BackgroundTransparency = 1,
        Position = UDim2.fromOffset(12, 0),
        Size = UDim2.new(0.44, -12, 1, 0),
        Font = FONT_MONO,
        TextSize = 13,
        TextColor3 = BASE.text,
        TextXAlignment = Enum.TextXAlignment.Left,
        Text = opts.text,
    }, row)
    local tb = inst("TextBox", {
        AnchorPoint = Vector2.new(1, 0.5),
        Position = UDim2.new(1, -10, 0.5, 0),
        Size = UDim2.new(0.56, -22, 0, 26),
        BackgroundColor3 = BASE.bg2,
        BorderSizePixel = 0,
        Font = FONT_MONO,
        TextSize = 12,
        TextColor3 = BASE.text,
        TextXAlignment = Enum.TextXAlignment.Left,
        Text = opts.value or "",
        PlaceholderText = opts.placeholder or "",
        PlaceholderColor3 = BASE.dim,
        ClearTextOnFocus = false,
    }, row)
    corner(tb, 6)
    outline(tb, 1.2)
    pad(tb, 8, 0, 8, 0)
    local s = accentStroke(tb, BASE.line, 1, 0.5)
    tb.Focused:Connect(function()
        s.Color = State.colors[win.key].a
        s.Transparency = 0.2
    end)
    tb.FocusLost:Connect(function()
        s.Color = BASE.line
        s.Transparency = 0.5
        if opts.callback then opts.callback(tb.Text) end
    end)
    return tb
end

function W.button(win, page, opts)
    local row = inst("Frame", {
        Size = UDim2.new(1, 0, 0, 34),
        BackgroundTransparency = 1,
        LayoutOrder = nextOrder(page),
    }, page)
    local glow = halo(row, State.colors[win.key].a, 11, 0.92)
    glow.Size = UDim2.new(1, 10, 0, 42)

    local b = inst("TextButton", {
        Size = UDim2.new(1, 0, 0, 34),
        BackgroundColor3 = BASE.panel,
        BorderSizePixel = 0,
        Font = FONT_MONO,
        TextSize = 13,
        TextColor3 = State.colors[win.key].a,
        Text = opts.text,
        AutoButtonColor = false,
    }, row)
    corner(b, 8)
    outline(b, 1.4)
    local edge = accentStroke(b, State.colors[win.key].a, 1, 0.55)
    local edge2
    if opts.extraOutline then
        edge2 = accentStroke(b, State.colors[win.key].a, 4, 0.3)
    end

    b.MouseEnter:Connect(function()
        tw(b, 0.14, { BackgroundColor3 = BASE.panel2 }, Enum.EasingStyle.Quint)
        tw(edge, 0.14, { Transparency = 0.15 })
        if edge2 then tw(edge2, 0.14, { Transparency = 0.05 }) end
        tw(glow, 0.14, { BackgroundTransparency = 0.72 })
    end)
    b.MouseLeave:Connect(function()
        tw(b, 0.16, { BackgroundColor3 = BASE.panel }, Enum.EasingStyle.Quint)
        tw(edge, 0.16, { Transparency = 0.55 })
        if edge2 then tw(edge2, 0.16, { Transparency = 0.3 }) end
        tw(glow, 0.16, { BackgroundTransparency = 0.92 })
    end)
    table.insert(win.onAccent, function()
        b.TextColor3 = State.colors[win.key].a
        edge.Color = State.colors[win.key].a
        if edge2 then edge2.Color = State.colors[win.key].a end
        glow.BackgroundColor3 = State.colors[win.key].a
    end)
    if opts.callback then b.MouseButton1Click:Connect(opts.callback) end
    return b
end

function W.cycle(win, page, opts)
    local i = 1
    for idx, v in ipairs(opts.options) do
        if v == opts.value then i = idx end
    end
    local b = W.button(win, page, { text = opts.text .. ": " .. opts.options[i] })
    b.MouseButton1Click:Connect(function()
        i = i % #opts.options + 1
        local v = opts.options[i]
        b.Text = opts.text .. ": " .. v
        if opts.callback then opts.callback(v) end
    end)
    return b
end

function W.colorPicker(win, page)
    local row = inst("Frame", {
        Size = UDim2.new(1, 0, 0, 40),
        BackgroundColor3 = BASE.panel,
        BackgroundTransparency = 0.25,
        BorderSizePixel = 0,
        LayoutOrder = nextOrder(page),
    }, page)
    corner(row, 8)
    outline(row, 1.2)
    inst("TextLabel", {
        BackgroundTransparency = 1,
        Position = UDim2.fromOffset(12, 0),
        Size = UDim2.new(0.4, -12, 1, 0),
        Font = FONT_MONO,
        TextSize = 13,
        TextColor3 = BASE.text,
        TextXAlignment = Enum.TextXAlignment.Left,
        Text = "Accent",
    }, row)

    local sw = 18
    local holder = inst("Frame", {
        AnchorPoint = Vector2.new(1, 0.5),
        Position = UDim2.new(1, -10, 0.5, 0),
        Size = UDim2.fromOffset(#SWATCHES * (sw + 4) - 4, sw),
        BackgroundTransparency = 1,
    }, row)
    for i, c in ipairs(SWATCHES) do
        local s = inst("TextButton", {
            Position = UDim2.fromOffset((i - 1) * (sw + 4), 0),
            Size = UDim2.fromOffset(sw, sw),
            BackgroundColor3 = c,
            BorderSizePixel = 0,
            Text = "",
            AutoButtonColor = false,
        }, holder)
        corner(s, 5)
        outline(s, 1.2)
        s.MouseButton1Click:Connect(function() setAccent(win, c) end)
    end

    local rs = W.slider(win, page, { text = "Red", min = 0, max = 255, step = 1, value = math.round(State.colors[win.key].a.R * 255),
        callback = function(v) pushRGB(win, v, nil, nil) end })
    local gs = W.slider(win, page, { text = "Green", min = 0, max = 255, step = 1, value = math.round(State.colors[win.key].a.G * 255),
        callback = function(v) pushRGB(win, nil, v, nil) end })
    local bs = W.slider(win, page, { text = "Blue", min = 0, max = 255, step = 1, value = math.round(State.colors[win.key].a.B * 255),
        callback = function(v) pushRGB(win, nil, nil, v) end })
    RGB[win.key] = { rs = rs, gs = gs, bs = bs }
end

function setAccent(win, color)
    State.colors[win.key].a = color
    State.colors[win.key].b = color:Lerp(Color3.new(1, 1, 1), 0.35)
    win:refreshAccent()
    local ref = RGB[win.key]
    if ref then
        ref.rs.set(math.round(color.R * 255))
        ref.gs.set(math.round(color.G * 255))
        ref.bs.set(math.round(color.B * 255))
    end
    refreshRailColors()
    saveThemes(true)
end

function pushRGB(win, r, g, b)
    local c = State.colors[win.key].a
    setAccent(win, Color3.new(
        r and r / 255 or c.R,
        g and g / 255 or c.G,
        b and b / 255 or c.B
    ))
end

function W.themeSaver(win, page)
    W.section(win, page, "Saving")
    W.button(win, page, {
        text = "Save theme",
        callback = function()
            local ok, err = saveThemes(false)
            if ok then
                notify("theme saved", State.colors[win.key].a)
                win:status("theme saved to " .. CONFIG_FILE)
            else
                notify("save failed: " .. tostring(err), RED)
            end
        end,
    })
    W.button(win, page, {
        text = "Reset to default",
        callback = function()
            setAccent(win, THEMES[win.key].a)
            saveThemes(false)
            notify("theme reset", THEMES[win.key].a)
        end,
    })
end

function W.vlist(win, page, opts)
    local H = opts.height or 190
    local rowH = opts.rowH or 30
    local poolSize = opts.pool or 14

    local frame = inst("Frame", {
        Size = UDim2.new(1, 0, 0, H),
        BackgroundColor3 = BASE.bg2,
        BackgroundTransparency = 0.2,
        BorderSizePixel = 0,
        ClipsDescendants = true,
        LayoutOrder = nextOrder(page),
    }, page)
    corner(frame, 8)
    outline(frame, 1.4)

    local sf = inst("ScrollingFrame", {
        Size = UDim2.new(1, -6, 1, -6),
        Position = UDim2.fromOffset(3, 3),
        BackgroundTransparency = 1,
        BorderSizePixel = 0,
        ScrollBarThickness = 3,
        ScrollBarImageColor3 = BASE.line,
        CanvasSize = UDim2.new(0, 0, 0, 0),
        ScrollingDirection = Enum.ScrollingDirection.Y,
    }, frame)

    local items, rows, bound = {}, {}, {}
    local render

    render = function()
        local top = sf.CanvasPosition.Y
        local first = math.max(1, math.floor(top / rowH))
        for i = 1, poolSize do
            local idx = first + i - 1
            local item = items[idx]
            local row = rows[i]
            bound[i] = item
            if item then
                row.Visible = true
                row.Position = UDim2.fromOffset(0, (idx - 1) * rowH)
                row.Text = opts.text(item)
                row.TextColor3 = BASE.text
                if opts.paint then opts.paint(item, row) end
            else
                row.Visible = false
            end
        end
    end

    for i = 1, poolSize do
        local row = inst("TextButton", {
            Size = UDim2.new(1, -6, 0, rowH - 2),
            BackgroundColor3 = BASE.panel,
            BackgroundTransparency = 0.35,
            BorderSizePixel = 0,
            Font = FONT_MONO,
            TextSize = 12,
            TextColor3 = BASE.text,
            TextXAlignment = Enum.TextXAlignment.Left,
            Text = "",
            AutoButtonColor = false,
            Visible = false,
        }, sf)
        corner(row, 6)
        outline(row, 1)
        pad(row, 8, 0, 8, 0)
        rows[i] = row
        row.MouseEnter:Connect(function()
            if bound[i] then
                tw(row, 0.12, { BackgroundColor3 = BASE.panel2, BackgroundTransparency = 0.1 }, Enum.EasingStyle.Quint)
            end
        end)
        row.MouseLeave:Connect(function()
            if bound[i] then
                tw(row, 0.16, { BackgroundColor3 = BASE.panel, BackgroundTransparency = 0.35 }, Enum.EasingStyle.Quint)
                if opts.paint then opts.paint(bound[i], row) end
            end
        end)
        row.MouseButton1Click:Connect(function()
            local item = bound[i]
            if item and opts.onRow then opts.onRow(item) end
        end)
    end

    local api = { frame = frame, sf = sf }
    function api.set(list)
        items = list
        sf.CanvasSize = UDim2.new(0, 0, 0, math.max(#items * rowH, 1))
        if sf.CanvasPosition.Y ~= 0 then sf.CanvasPosition = Vector2.new(0, 0) end
        render()
    end
    function api.refresh() render() end

    track(sf:GetPropertyChangedSignal("CanvasPosition"):Connect(render))
    track(sf:GetPropertyChangedSignal("AbsoluteSize"):Connect(render))
    return api
end

-- ---------------------------------------------------------------- style tab
local doUnload
local applyAllStyles

do
    local function applyRounds()
        for _, e in ipairs(CORNERS) do
            if e.ui.Parent then e.ui.CornerRadius = UDim.new(0, math.min(e.r, STYLE.round)) end
        end
    end
    local function applyOutlines()
        for _, e in ipairs(OUTLINES) do
            if e.s.Parent then e.s.Thickness = math.max(e.base * STYLE.outline, 0.2) end
        end
    end
    local function applyGlows()
        for _, h in ipairs(HALOS) do
            if h.Parent then h.Visible = STYLE.glow end
        end
    end
    local function applyScales()
        for _, w in pairs(WINDOWS) do
            if w.scale then w.scale.Scale = STYLE.scale end
        end
    end
    local function applyScans()
        for _, w in pairs(WINDOWS) do applyScan(w, STYLE.scan) end
    end
    local function applyBgs()
        for k, w in pairs(WINDOWS) do applyBackground(w, STYLE.bg[k] or "classic") end
    end

    applyAllStyles = function()
        applyRounds(); applyOutlines(); applyGlows(); applyScales(); applyScans(); applyBgs()
    end

    function W.styleTab(win, page)
        W.section(win, page, "Background")
        W.cycle(win, page, {
            text = "Pattern",
            options = BG_KINDS,
            value = STYLE.bg[win.key] or "classic",
            callback = function(v)
                STYLE.bg[win.key] = v
                applyBackground(win, v)
                saveThemes(true)
            end,
        })
        local bgToken = 0
        W.slider(win, page, {
            text = "Pattern strength", min = 0, max = 1, step = 0.05, value = STYLE.opacity,
            callback = function(v)
                STYLE.opacity = v
                bgToken += 1
                local t = bgToken
                task.delay(0.15, function()
                    if t == bgToken then applyBgs() end
                end)
                saveThemes(true)
            end,
        })
        W.toggle(win, page, {
            text = "Scanlines", value = STYLE.scan,
            callback = function(v) STYLE.scan = v; applyScans(); saveThemes(true) end,
        })

        W.section(win, page, "Image background")
        W.note(win, page, "Files in the OJBS_Images folder of your executor workspace show up below. A local file only exists on this machine; an rbxassetid:// link is the one that works for everyone running the script.")

        local imgList
        local imgCount
        local function refreshImgList()
            if not imgList then return end
            local files = IMG.files()
            imgList.set(files)
            if imgCount then
                imgCount.Text = IMG.available() and (#files .. " image(s) found") or "file api unavailable in this executor"
            end
        end

        local imgInput = W.input(win, page, { text = "Image", placeholder = "rbxassetid://123, https://..., or OJBS_Images/a.png" })
        W.button(win, page, {
            text = "Use this image for this window",
            callback = function()
                local raw = string.gsub(imgInput.Text or "", "^%s+", "")
                raw = string.gsub(raw, "%s+$", "")
                if raw == "" then notify("paste a link or path first", RED) return end
                local src = raw
                if string.match(raw, "^https?://") then
                    local ok, path = IMG.import(raw)
                    if not ok then notify("import failed: " .. tostring(path), RED) return end
                    src = path
                elseif not (string.find(raw, "rbxassetid://", 1, true) or string.find(raw, "rbxasset://", 1, true)) then
                    local okf, exists = pcall(function() return isfile(raw) end)
                    if not okf or not exists then notify("file not found: " .. raw, RED) return end
                end
                if not IMG.resolve(src) then notify("image could not be loaded", RED) return end
                STYLE.image[win.key] = src
                applyBackground(win, STYLE.bg[win.key] or "classic")
                saveThemes(true)
                refreshImgList()
                notify("background set", State.colors[win.key].a)
            end,
        })

        imgList = W.vlist(win, page, {
            height = 120,
            rowH = 26,
            text = function(e) return e.name end,
            onRow = function(e)
                if not IMG.resolve(e.path) then notify("could not load " .. e.name, RED) return end
                STYLE.image[win.key] = e.path
                applyBackground(win, STYLE.bg[win.key] or "classic")
                saveThemes(true)
                notify("background: " .. e.name, State.colors[win.key].a)
            end,
        })

        imgCount = inst("TextLabel", {
            BackgroundTransparency = 1,
            Size = UDim2.new(1, 0, 0, 16),
            Font = FONT_MONO,
            TextSize = 11,
            TextColor3 = BASE.dim,
            TextXAlignment = Enum.TextXAlignment.Left,
            Text = "",
            LayoutOrder = nextOrder(page),
        }, page)

        W.button(win, page, {
            text = "Rescan image folder",
            callback = function()
                IMG.ensure()
                refreshImgList()
                notify("folder: " .. IMG.dir, BASE.dim)
            end,
        })
        W.button(win, page, {
            text = "Remove image from this window",
            callback = function()
                STYLE.image[win.key] = ""
                applyBackground(win, STYLE.bg[win.key] or "classic")
                saveThemes(true)
                notify("image removed", BASE.dim)
            end,
        })
        W.cycle(win, page, {
            text = "Image fit",
            options = { "Crop", "Stretch", "Fit" },
            value = STYLE.imgFit,
            callback = function(v)
                STYLE.imgFit = v
                applyBgs()
                saveThemes(true)
            end,
        })
        W.slider(win, page, {
            text = "Image transparency", min = 0, max = 1, step = 0.05, value = STYLE.imgTrans,
            callback = function(v)
                STYLE.imgTrans = v
                applyBgs()
                saveThemes(true)
            end,
        })
        refreshImgList()

        W.section(win, page, "Shape")
        W.cycle(win, page, {
            text = "Corners",
            options = { "Sharp", "Boxed", "Soft" },
            value = (STYLE.round <= 1) and "Sharp" or ((STYLE.round >= 10) and "Soft" or "Boxed"),
            callback = function(v)
                STYLE.round = (v == "Sharp") and 0 or ((v == "Soft") and 14 or 4)
                applyRounds(); saveThemes(true)
            end,
        })
        W.slider(win, page, {
            text = "Outline weight", min = 0.4, max = 2.5, step = 0.05, value = STYLE.outline,
            callback = function(v) STYLE.outline = v; applyOutlines(); saveThemes(true) end,
        })
        W.toggle(win, page, {
            text = "Button glow", value = STYLE.glow,
            callback = function(v) STYLE.glow = v; applyGlows(); saveThemes(true) end,
        })
        W.slider(win, page, {
            text = "Window scale", min = 0.8, max = 1.4, step = 0.02, value = STYLE.scale,
            callback = function(v) STYLE.scale = v; applyScales(); saveThemes(true) end,
        })

        W.section(win, page, "Accent")
        W.button(win, page, {
            text = "Copy accent to all windows",
            callback = function()
                local c = State.colors[win.key].a
                for _, st in pairs(State.colors) do
                    st.a = c
                    st.b = c:Lerp(Color3.new(1, 1, 1), 0.35)
                end
                for _, w in pairs(WINDOWS) do w:refreshAccent() end
                refreshRailColors()
                saveThemes(false)
                notify("accent copied to every window", c)
            end,
        })

        W.section(win, page, "Danger")
        W.button(win, page, {
            text = "Wipe saved settings",
            callback = function()
                local ok = pcall(function()
                    if delfile and isfile and isfile(CONFIG_FILE) then delfile(CONFIG_FILE) end
                end)
                notify(ok and "saved settings wiped" or "file api blocked", RED)
            end,
        })
        W.button(win, page, {
            text = "UNLOAD UI  ·  full teardown",
            callback = function() if doUnload then doUnload() end end,
        })
    end
end

track(UIS.InputChanged:Connect(function(input)
    if not W.dragState then return end
    if input.UserInputType ~= Enum.UserInputType.MouseMovement and input.UserInputType ~= Enum.UserInputType.Touch then return end
    W.dragState(input.Position.X)
end))
track(UIS.InputEnded:Connect(function(input)
    if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
        W.dragState = nil
    end
end))

-- ---------------------------------------------------------------- picking
local pendingPick = nil
local pendingDest = nil

local function armPick(cb, label)
    pendingPick = cb
    notify(label or "click a player", State.colors.m1.a)
end

local function aimPoint()
    local cam = Workspace.CurrentCamera
    if not cam then return nil end
    if Mouse.Target and Mouse.Hit then return Mouse.Hit.Position end
    local rp = RaycastParams.new()
    rp.FilterType = Enum.RaycastFilterType.Exclude or Enum.RaycastFilterType.Blacklist
    rp.FilterDescendantsInstances = { LP.Character }
    local ray = cam:ViewportPointToRay(Mouse.X, Mouse.Y)
    local hit = Workspace:Raycast(ray.Origin, ray.Direction * 5000, rp)
    return hit and hit.Position or (ray.Origin + ray.Direction * 400)
end

-- ---------------------------------------------------------------- M1 engine
local SkillRemote  = ReplicatedStorage.NetworkComm.SkillService.StartSkilll_Method
local DamageRemote = ReplicatedStorage.NetworkComm.CombatService.DamageCharacter_Method

local M1 = {
    slots = {},
    moves = { list = {}, enabled = false, rate = 30, idx = 0, acc = 0, inflight = 0, at = 0 },
    npcs = {}, npcsAt = 0,
}

local function newSlot(cfg)
    return {
        target = nil, box = nil, enabled = false,
        rate = cfg.rate or 30,
        size = cfg.size or 160,
        alpha = cfg.alpha or 0.75,
        color = cfg.color or Color3.fromRGB(255, 60, 60),
        skill = cfg.skill or "Punch",
        origin = cfg.origin or "Target (ground)",
        argMode = cfg.argMode or "none",
        useDamage = cfg.useDamage ~= false,
        idx = 0, acc = 0, inflight = 0, at = 0,
    }
end

M1.slots.punch = newSlot({ skill = "Punch", rate = 50, size = 200, argMode = "1,1" })
M1.slots.burst = newSlot({ skill = "AwakenedLimitlessReversalBurst", rate = 40, size = 140, argMode = "none", color = Color3.fromRGB(255, 120, 60) })
M1.slots.nuke  = newSlot({ skill = "AwakenedLimitlessHollowNuke", rate = 60, size = 90, argMode = "targets", color = Color3.fromRGB(255, 170, 60) })

local function scanNPCs()
    local now = os.clock()
    if now - M1.npcsAt < 0.15 and #M1.npcs > 0 then return M1.npcs end
    M1.npcsAt = now
    local out = {}
    local f = npcsFolder()
    if f then
        for _, m in ipairs(f:GetChildren()) do
            if m:IsA("Model") and rootOf(m) then out[#out + 1] = m end
        end
    end
    M1.npcs = out
    return out
end

-- ground point under the target, exactly like the capture (y ~ 0.0001)
local function castOrigin(slot, myChar, targets, target)
    local myRoot = rootOf(myChar)
    if not myRoot then return nil end
    local base = myRoot.Position
    local point = base

    if slot.origin ~= "Self" and slot.origin ~= "Self (ground)" then
        local pick = target
        if not pick then
            local bestD
            for _, t in ipairs(targets) do
                local r = rootOf(t)
                if r then
                    local d = (r.Position - base).Magnitude
                    if not bestD or d < bestD then pick, bestD = t, d end
                end
            end
        end
        local pr = pick and rootOf(pick)
        if pr then point = pr.Position end
    end

    if slot.origin == "Target (ground)" or slot.origin == "Self (ground)" then
        local rp = RaycastParams.new()
        rp.FilterType = Enum.RaycastFilterType.Exclude or Enum.RaycastFilterType.Blacklist
        local filter = { myChar }
        if target then filter[#filter + 1] = target end
        rp.FilterDescendantsInstances = filter
        local hit = Workspace:Raycast(point + Vector3.new(0, 3, 0), Vector3.new(0, -150, 0), rp)
        if hit then point = hit.Position end
    end
    return point
end

local function ensureBox(slot, myChar, id)
    local r = rootOf(myChar)
    if not r then return end
    if not slot.box or not slot.box.Parent then
        slot.box = inst("Part", {
            Name = "OJBS_Box_" .. tostring(id),
            Anchored = true, CanCollide = false, CanQuery = false, CanTouch = false, CastShadow = false,
            Material = Enum.Material.ForceField,
            Parent = Workspace,
        })
    end
    slot.box.Size = Vector3.new(slot.size, slot.size, slot.size)
    slot.box.Transparency = slot.alpha
    slot.box.Color = slot.color
    slot.box.CFrame = CFrame.new(r.Position)
end

local function collectTargets(slot)
    local out = {}
    local myChar = slot.target
    if not myChar or not myChar.Parent then return out end
    local r = rootOf(myChar)
    if not r then return out end
    local pos, h = r.Position, slot.size / 2
    for _, m in ipairs(scanNPCs()) do
        local nr = rootOf(m)
        if nr then
            local d = nr.Position - pos
            if math.abs(d.X) <= h and math.abs(d.Y) <= h and math.abs(d.Z) <= h then
                out[#out + 1] = m
            end
        end
    end
    return out
end

local function bump(group)
    local now = os.clock()
    if group.inflight >= MAX_INFLIGHT then
        if now - (group.at or 0) > 2 then
            group.inflight = 0
        else
            return false
        end
    end
    group.inflight += 1
    group.at = now
    return true
end

-- StartSkill + DamageCharacter, exactly the two calls in the captures:
-- StartSkill(skill, caster, groundPos, {}, [targets])
-- DamageCharacter({npc}, true, {WindowID, LocalCharacter, SkillID})
local function fire(group, myChar, skillId, origin, targets, target, argMode, useDamage)
    if not bump(group) then return end
    task.spawn(function()
        pcall(function()
            if argMode == "targets" then
                SkillRemote:InvokeServer(skillId, myChar, origin, {}, targets)
            elseif argMode == "1,1" then
                SkillRemote:InvokeServer(skillId, myChar, origin, {}, 1, 1)
            else
                SkillRemote:InvokeServer(skillId, myChar, origin, {})
            end
            if useDamage and target then
                DamageRemote:InvokeServer({ target }, true, {
                    WindowID = myChar.Name .. "_" .. skillId,
                    LocalCharacter = myChar,
                    SkillID = skillId,
                })
            end
        end)
        group.inflight -= 1
    end)
end

local function runSlot(slot, dt)
    if not slot.enabled then
        if slot.box then slot.box:Destroy(); slot.box = nil end
        return
    end
    local myChar = slot.target
    if not myChar or not myChar.Parent then
        if slot.box then slot.box:Destroy(); slot.box = nil end
        return
    end
    ensureBox(slot, myChar, slot.skill)

    slot.acc += dt * slot.rate
    local n = math.floor(slot.acc)
    if n <= 0 then return end
    slot.acc -= n
    if n > MAX_TICK then n = MAX_TICK end

    local targets = collectTargets(slot)
    if #targets == 0 then return end

    for _ = 1, n do
        slot.idx = slot.idx + 1
        local t = targets[(slot.idx - 1) % #targets + 1]
        local origin = castOrigin(slot, myChar, targets, t)
        if origin then
            fire(slot, myChar, slot.skill, origin, targets, t, slot.argMode, slot.useDamage)
        end
    end
end

local function runMoves(dt)
    if not M1.moves.enabled then return end
    local base = M1.slots.punch
    local myChar = base.target
    if not myChar or not myChar.Parent then return end

    M1.moves.acc += dt * M1.moves.rate
    local n = math.floor(M1.moves.acc)
    if n <= 0 then return end
    M1.moves.acc -= n
    if n > MAX_TICK then n = MAX_TICK end

    local targets = collectTargets(base)
    if #targets == 0 then return end

    local active = {}
    for _, mv in ipairs(M1.moves.list) do
        if mv.on then active[#active + 1] = mv end
    end
    if #active == 0 then return end

    for _ = 1, n do
        M1.moves.idx = M1.moves.idx + 1
        local mv = active[(M1.moves.idx - 1) % #active + 1]
        local t = targets[(M1.moves.idx - 1) % #targets + 1]
        local origin = castOrigin(base, myChar, targets, t)
        if origin then
            fire(M1.moves, myChar, "AwakenedLimitless" .. mv.name, origin, targets, t, "targets", true)
        end
    end
end

-- ---------------------------------------------------------------- teleport engine
local TP = { root = nil, orig = nil, name = nil, dest = nil, running = false, interval = 0.1, acc = 0, onStatus = nil }

local function tpSay(msg, color)
    if TP.onStatus then TP.onStatus(msg) end
    notify(msg, color or State.colors.tp.a)
end

local function tpLock(model)
    local r = rootOf(model)
    if not r then tpSay("no root on " .. model.Name, RED) return end
    TP.root, TP.orig, TP.name = r, r.CFrame, model.Name
    tpSay("locked " .. model.Name)
end

local function tpSetDest(p)
    TP.dest = p
    TP.running = true
    TP.acc = 0
    TP.lift = nil
    tpSay("teleport running")
end

local function tpToggle()
    if not TP.dest then tpSay("pick a spot first", RED) return end
    TP.running = not TP.running
    tpSay(TP.running and "teleport on" or "teleport paused")
end

local function tpReset()
    TP.running = false
    if TP.root and TP.root.Parent and TP.orig then
        TP.root.CFrame = TP.orig
        TP.root.AssemblyLinearVelocity = Vector3.zero
        TP.root.AssemblyAngularVelocity = Vector3.zero
    end
    TP.root, TP.orig, TP.name, TP.dest = nil, nil, nil, nil
    tpSay("reset")
end



-- ---------------------------------------------------------------- M1 window
local m1Win = makeWindow("m1", "M1 Box", USE_EMOJI and "👊" or "M1")

local pGuide  = m1Win:addTab("Guide")
local pMain   = m1Win:addTab("Main")
local pBurst  = m1Win:addTab("Red Burst")
local pNuke   = m1Win:addTab("Hollow Nuke")
local pMoves  = m1Win:addTab("Moves")
local pListen = m1Win:addTab("Listener")
local pLib    = m1Win:addTab("Library")
local pVisual = m1Win:addTab("Visuals")
local pColorM = m1Win:addTab("Settings")
m1Win:selectTab(2)

local ARG_MODES = { "targets", "none", "1,1" }

do
    W.section(m1Win, pGuide, "Quick start")
    W.note(m1Win, pGuide, "Open the page you want in this tab, press the Click torso button, then click your own torso. Turn True Six Eyes off first — its hitbox sits over your body and swallows the click. After that, set the box size and hits per second, then flip Enable on.")
    W.section(m1Win, pGuide, "1 · Pick a target")
    W.note(m1Win, pGuide, "Press Click torso · select player, then click the torso of whoever you want to hit. Every slot keeps its own target, so Punch, Red Burst and Hollow Nuke each need their own pick.")
    W.section(m1Win, pGuide, "2 · Set size and rate")
    W.note(m1Win, pGuide, "Box size is how wide the hitbox following the target is. Casts / sec is how often the move fires. Start low, raise it until hits stop landing, then drop back one step.")
    W.section(m1Win, pGuide, "3 · Turn it on")
    W.note(m1Win, pGuide, "Enable switches that slot on. STOP on the footer turns every slot off and removes the remote hook, so the game behaves normally again.")
    W.section(m1Win, pGuide, "Tips")
    W.note(m1Win, pGuide, "Hollow Nuke hits the hardest of the three by a wide margin, but it is slow — without cooldown reduction you spend most of the fight waiting on it.")
    W.note(m1Win, pGuide, "More moves: open Listener, turn on Listen for new moves, cast a skill once in game, pick it from the captures and press Add to library. It stays saved per place.")
end

local function buildSlotControls(page, slot, opts)
    opts = opts or {}
    W.section(m1Win, page, "Target")
    local selBtn
    selBtn = W.button(m1Win, page, {
        text = slot.target and ("Target: " .. slot.target.Name) or "Click torso · select player",
        extraOutline = true,
        callback = function()
            armPick(function(m)
                slot.target = m
                selBtn.Text = "Target: " .. m.Name
                m1Win:status("locked " .. m.Name)
            end, "click a player")
        end,
    })

    W.section(m1Win, page, "Firing")
    slot.ui = W.toggle(m1Win, page, {
        text = "Enable",
        value = slot.enabled,
        callback = function(v)
            slot.enabled = v
            if not v and slot.box then slot.box:Destroy(); slot.box = nil end
        end,
    })
    W.slider(m1Win, page, { text = "Casts / sec", min = 1, max = 100000, step = 1, value = slot.rate, callback = function(v) slot.rate = v end })
    W.slider(m1Win, page, { text = "Box size", min = 1, max = 750, step = 1, value = slot.size, callback = function(v) slot.size = v end })
    W.cycle(m1Win, page, {
        text = "Origin",
        options = { "Target (ground)", "Target", "Self (ground)", "Self" },
        value = slot.origin,
        callback = function(v) slot.origin = v end,
    })
    W.cycle(m1Win, page, {
        text = "StartSkill args",
        options = ARG_MODES,
        value = slot.argMode,
        callback = function(v) slot.argMode = v end,
    })
    W.toggle(m1Win, page, {
        text = "DamageCharacter",
        value = slot.useDamage,
        callback = function(v) slot.useDamage = v end,
    })

    if opts.skillInput then
        W.input(m1Win, page, {
            text = "Skill ID",
            value = slot.skill,
            callback = function(v) if v ~= "" then slot.skill = v end end,
        })
    end
end

buildSlotControls(pMain, M1.slots.punch)
buildSlotControls(pBurst, M1.slots.burst, { skillInput = true })
buildSlotControls(pNuke, M1.slots.nuke, { skillInput = true })

W.section(m1Win, pMoves, "Add move")
local moveNameBox = W.input(m1Win, pMoves, { text = "Move", placeholder = "HollowNuke" })
local movesHolder = inst("Frame", {
    Size = UDim2.new(1, 0, 0, 0),
    AutomaticSize = Enum.AutomaticSize.Y,
    BackgroundTransparency = 1,
    LayoutOrder = 900,
}, pMoves)
inst("UIListLayout", { Padding = UDim.new(0, 6), SortOrder = Enum.SortOrder.LayoutOrder }, movesHolder)

local moveRows = {}

local function refreshMoves()
    for _, r in ipairs(moveRows) do r:Destroy() end
    moveRows = {}
    for i, mv in ipairs(M1.moves.list) do
        local row = inst("TextButton", {
            Size = UDim2.new(1, 0, 0, 32),
            BackgroundColor3 = mv.on and BASE.panel2 or BASE.panel,
            BackgroundTransparency = mv.on and 0.05 or 0.35,
            BorderSizePixel = 0,
            Font = FONT_MONO,
            TextSize = 12,
            TextColor3 = mv.on and State.colors.m1.a or BASE.text,
            TextXAlignment = Enum.TextXAlignment.Left,
            Text = "  " .. mv.name,
            AutoButtonColor = false,
            LayoutOrder = i,
        }, movesHolder)
        corner(row, 6)
        outline(row, 1)
        row.MouseEnter:Connect(function()
            tw(row, 0.12, { BackgroundTransparency = mv.on and 0.0 or 0.12 }, Enum.EasingStyle.Quint)
        end)
        row.MouseLeave:Connect(function()
            tw(row, 0.16, { BackgroundTransparency = mv.on and 0.05 or 0.35 }, Enum.EasingStyle.Quint)
        end)
        row.MouseButton1Click:Connect(function()
            mv.on = not mv.on
            refreshMoves()
        end)
        local x = inst("TextButton", {
            AnchorPoint = Vector2.new(1, 0.5),
            Position = UDim2.new(1, -6, 0.5, 0),
            Size = UDim2.fromOffset(24, 22),
            BackgroundTransparency = 1,
            Text = "✕",
            Font = FONT_MONO,
            TextSize = 12,
            TextColor3 = BASE.dim,
            AutoButtonColor = false,
        }, row)
        x.MouseButton1Click:Connect(function()
            table.remove(M1.moves.list, i)
            refreshMoves()
        end)
        moveRows[#moveRows + 1] = row
    end
end

W.button(m1Win, pMoves, {
    text = "Add move",
    callback = function()
        local n = moveNameBox.Text
        if n == "" then return end
        if string.sub(n, 1, 19) == "AwakenedLimitless" then n = string.sub(n, 20) end
        table.insert(M1.moves.list, { name = n, on = true })
        moveNameBox.Text = ""
        refreshMoves()
    end,
})

W.section(m1Win, pMoves, "Firing")
M1.movesUI = W.toggle(m1Win, pMoves, { text = "Enable moves", value = false, callback = function(v) M1.moves.enabled = v end })
W.slider(m1Win, pMoves, { text = "Casts / sec", min = 1, max = 100000, step = 1, value = 30, callback = function(v) M1.moves.rate = v end })

refreshMoves()

-- ---------------------------------------------------------------- move library
local LIB_FILE = "OJBS_LIB.json"
local LIB = { entries = {}, byId = {} }
local Capture = { list = {}, byId = {} }

local function libReadAll()
    local ok, data = pcall(function()
        if not (isfile and isfile(LIB_FILE)) then return {} end
        local d = HttpService:JSONDecode(readfile(LIB_FILE))
        if type(d) == "table" then return d end
        return {}
    end)
    if ok and type(data) == "table" then return data end
    return {}
end

local libToken = 0
local function libSave(deferred)
    libToken += 1
    local t = libToken
    local function commit()
        local data = libReadAll()
        local out = {}
        for _, e in ipairs(LIB.entries) do
            out[#out + 1] = {
                id = e.id,
                name = e.name,
                rate = e.slot.rate,
                size = e.slot.size,
                origin = e.slot.origin,
                argMode = e.slot.argMode,
                useDamage = e.slot.useDamage,
            }
        end
        data[tostring(game.PlaceId)] = out
        pcall(function() writefile(LIB_FILE, HttpService:JSONEncode(data)) end)
    end
    if not deferred then return commit() end
    task.delay(0.8, function()
        if t == libToken then commit() end
    end)
end

local libList, libCount, libSearch
local captureList, capCount
local openDetail, closeDetail
local refreshCapture

local function libFilter()
    local q = string.lower((libSearch and libSearch.Text) or "")
    local out = {}
    for _, e in ipairs(LIB.entries) do
        if q == "" or string.find(e.search, q, 1, true) then out[#out + 1] = e end
    end
    return out
end

local function libRefresh()
    if libList then libList.set(libFilter()) end
    if libCount then libCount.Text = #LIB.entries .. " saved" end
end

local function addToLib(id, name)
    local e = LIB.byId[id]
    if e then
        notify("already in library", RED)
        return e
    end
    local slot = newSlot({
        skill = id,
        rate = 30,
        size = 140,
        argMode = "targets",
        useDamage = true,
        color = Color3.fromRGB(255, 196, 92),
    })
    e = { id = id, name = name or id, slot = slot, search = string.lower((name or id) .. " " .. id) }
    LIB.entries[#LIB.entries + 1] = e
    LIB.byId[id] = e
    M1.slots["lib:" .. id] = slot
    libSave(true)
    libRefresh()
    notify("saved " .. e.name, State.colors.m1.a)
    return e
end

local function removeFromLib(e)
    if e.slot.box then pcall(function() e.slot.box:Destroy() end) end
    M1.slots["lib:" .. e.id] = nil
    LIB.byId[e.id] = nil
    for i, x in ipairs(LIB.entries) do
        if x == e then
            table.remove(LIB.entries, i)
            break
        end
    end
    for _, c in ipairs(Capture.list) do
        if c.id == e.id then c.saved = false end
    end
    libSave(true)
    libRefresh()
    refreshCapture()
end

local function loadLibrary()
    local data = libReadAll()
    local list = data[tostring(game.PlaceId)]
    if type(list) ~= "table" then return end
    for _, rec in ipairs(list) do
        if type(rec) == "table" and type(rec.id) == "string" and not LIB.byId[rec.id] then
            local slot = newSlot({
                skill = rec.id,
                rate = tonumber(rec.rate) or 30,
                size = tonumber(rec.size) or 140,
                origin = rec.origin,
                argMode = rec.argMode or "targets",
                useDamage = rec.useDamage ~= false,
                color = Color3.fromRGB(255, 196, 92),
            })
            local name = rec.name or rec.id
            local e = { id = rec.id, name = name, slot = slot, search = string.lower(name .. " " .. rec.id) }
            LIB.entries[#LIB.entries + 1] = e
            LIB.byId[rec.id] = e
            M1.slots["lib:" .. rec.id] = slot
        end
    end
end
loadLibrary()

-- ---------------------------------------------------------------- skill listener
local EXCLUDED = {
    Punch = true,
    AwakenedLimitlessReversalBurst = true,
    AwakenedLimitlessHollowNuke = true,
}

local ListenOn = false
local hookState = { live = false, installed = false, err = nil, prev = nil }

local CRATE = {
    list = {}, byId = {}, selected = nil,
    listening = false, running = false,
    sent = 0, inflight = 0, at = 0,
    names = {},
}
local crateHook = { installed = false, err = nil, prev = nil }
local NAME_CACHE = {}

local function skillDisplayName(id)
    if NAME_CACHE[id] then return NAME_CACHE[id] end

    local name
    local cfgs = ReplicatedStorage:FindFirstChild("Configs")
    if cfgs then
        local seen = {}
        local function walk(t, depth)
            if name or type(t) ~= "table" or depth > 4 or seen[t] then return end
            seen[t] = true
            for k, v in pairs(t) do
                if type(v) == "table" then
                    local nm = v.Name or v.DisplayName or v.SkillName
                    if type(nm) == "string" and (k == id or v.ID == id or v.Id == id or v.SkillID == id or v.SkillId == id) then
                        name = nm
                        return
                    end
                    walk(v, depth + 1)
                    if name then return end
                end
            end
        end
        for _, child in ipairs(cfgs:GetChildren()) do
            if child:IsA("ModuleScript") then
                local ok, data = pcall(require, child)
                if ok and type(data) == "table" then
                    local hit = data[id]
                    if type(hit) == "table" then
                        local nm = hit.Name or hit.DisplayName or hit.SkillName
                        if type(nm) == "string" then name = nm end
                    end
                    if not name then walk(data, 0) end
                end
                if name then break end
            end
        end
    end

    if not name then
        name = id
        for _, pre in ipairs({ "AwakenedLimitless", "Awakened", "Limitless" }) do
            if string.sub(name, 1, #pre) == pre then
                name = string.sub(name, #pre + 1)
                break
            end
        end
    end
    NAME_CACHE[id] = name
    return name
end

refreshCapture = function()
    if captureList then captureList.set(Capture.list) end
    if capCount then capCount.Text = #Capture.list .. " captured" end
end

local function pushCapture(id)
    if Capture.byId[id] then return end
    local e = { id = id, name = id, saved = LIB.byId[id] ~= nil }
    Capture.byId[id] = e
    Capture.list[#Capture.list + 1] = e
    refreshCapture()
    task.defer(function()
        e.name = skillDisplayName(id)
        refreshCapture()
        notify("caught " .. e.name, State.colors.m1.a)
    end)
end

local function recordSkill(id)
    if not ListenOn then return end
    if type(id) ~= "string" or id == "" or EXCLUDED[id] then return end
    pushCapture(id)
end

local function installHook()
    if hookState.installed then return hookState.live end
    if not (hookmetamethod and getrawmetatable and getnamecallmethod) then
        hookState.err = "executor has no hookmetamethod"
        return false
    end
    local ok, err = pcall(function()
        local prev
        prev = hookmetamethod(game, "__namecall", function(self, ...)
            if ListenOn and self == SkillRemote then
                local okm, method = pcall(getnamecallmethod)
                if okm and method == "InvokeServer" then
                    local ours = false
                    if checkcaller then
                        local cok, c = pcall(checkcaller)
                        ours = cok and c or false
                    end
                    if not ours then
                        local a1 = ...
                        if type(a1) == "string" then task.defer(recordSkill, a1) end
                    end
                end
            end
            return prev(self, ...)
        end)
        hookState.prev = prev
    end)
    if not ok then
        hookState.err = tostring(err)
        return false
    end
    hookState.installed = true
    hookState.live = true
    return true
end

-- restores the original __namecall so nothing intercepts remotes while the listener is off
local function uninstallHook()
    if not hookState.installed then return true end
    local prev = hookState.prev
    local restored = false
    if prev then
        restored = pcall(hookmetamethod, game, "__namecall", prev)
        if not restored and restorefunction then
            restored = pcall(restorefunction, prev)
        end
    end
    if not restored then
        hookState.err = "executor could not restore __namecall"
        return false
    end
    hookState.prev = nil
    hookState.installed = false
    hookState.live = false
    hookState.err = nil
    return true
end

-- ---------------------------------------------------------------- listener tab
W.section(m1Win, pListen, "Capture")

local listenHint = inst("TextLabel", {
    BackgroundTransparency = 1,
    Size = UDim2.new(1, 0, 0, 16),
    Font = FONT_MONO,
    TextSize = 11,
    TextColor3 = BASE.dim,
    TextXAlignment = Enum.TextXAlignment.Left,
    Text = "fired skills land here · punch, burst and nuke are ignored",
    LayoutOrder = nextOrder(pListen),
}, pListen)

local listenToggle
listenToggle = W.toggle(m1Win, pListen, {
    text = "Listen for new moves",
    value = false,
    callback = function(v)
        ListenOn = v
        if v then CRATE.stopListen() end
        if not v then
            if uninstallHook() then
                notify("listener off · hook removed", BASE.dim)
            else
                notify("listener off · " .. tostring(hookState.err), RED)
            end
            return
        end
        if installHook() then
            notify("listening", State.colors.m1.a)
            m1Win:status("hook installed")
        else
            ListenOn = false
            listenToggle.set(false)
            notify("hook failed: " .. tostring(hookState.err), RED)
            m1Win:status("hook failed")
        end
    end,
})

capCount = inst("TextLabel", {
    BackgroundTransparency = 1,
    Size = UDim2.new(1, 0, 0, 16),
    Font = FONT_MONO,
    TextSize = 11,
    TextColor3 = BASE.dim,
    TextXAlignment = Enum.TextXAlignment.Left,
    Text = "0 captured",
    LayoutOrder = nextOrder(pListen),
}, pListen)

captureList = W.vlist(m1Win, pListen, {
    height = 168,
    rowH = 30,
    text = function(e)
        return (e.saved and "✓  " or "+  ") .. e.name .. "   ·   " .. e.id
    end,
    paint = function(e, row)
        row.TextColor3 = e.saved and State.colors.m1.b or BASE.text
    end,
    onRow = function(e)
        local entry = LIB.byId[e.id]
        if entry then
            openDetail(entry)
            return
        end
        addToLib(e.id, e.name)
        e.saved = true
        refreshCapture()
    end,
})

W.button(m1Win, pListen, {
    text = "Save all captured",
    callback = function()
        local n = 0
        for _, e in ipairs(Capture.list) do
            if not LIB.byId[e.id] then
                addToLib(e.id, e.name)
                e.saved = true
                n += 1
            end
        end
        refreshCapture()
        notify(n > 0 and ("saved " .. n .. " moves") or "nothing new to save", n > 0 and State.colors.m1.a or RED)
    end,
})
W.button(m1Win, pListen, {
    text = "Clear captures",
    callback = function()
        Capture.list, Capture.byId = {}, {}
        refreshCapture()
    end,
})

local function panicStop()
    for _, slot in pairs(M1.slots) do
        slot.enabled = false
        slot.acc, slot.idx = 0, 0
        if slot.box then pcall(function() slot.box:Destroy() end); slot.box = nil end
        if slot.ui and slot.ui.frame and slot.ui.frame.Parent then pcall(slot.ui.set, false) end
    end
    M1.moves.enabled = false
    CRATE.stop()
    M1.moves.acc, M1.moves.idx = 0, 0
    if M1.movesUI and M1.movesUI.frame and M1.movesUI.frame.Parent then pcall(M1.movesUI.set, false) end
    ListenOn = false
    if listenToggle and listenToggle.frame.Parent then pcall(listenToggle.set, false) end
    local unhooked = uninstallHook()
    if not CRATE.stopListen() then unhooked = false end
    m1Win:status(unhooked and "stopped · hook removed" or "stopped · hook stuck")
    notify(unhooked and "all stopped · remotes untouched" or ("stopped · " .. tostring(hookState.err)), RED)
end

local stopBtn = inst("TextButton", {
    AnchorPoint = Vector2.new(1, 0.5),
    Position = UDim2.new(1, -14, 0.5, 0),
    Size = UDim2.fromOffset(58, 20),
    BackgroundColor3 = BASE.panel,
    BorderSizePixel = 0,
    Font = FONT_MONO,
    TextSize = 10,
    TextColor3 = RED,
    Text = "STOP",
    AutoButtonColor = false,
}, m1Win.footer)
corner(stopBtn, 6)
outline(stopBtn, 1.1)
stopBtn.MouseEnter:Connect(function() tw(stopBtn, 0.12, { BackgroundColor3 = BASE.panel2 }) end)
stopBtn.MouseLeave:Connect(function() tw(stopBtn, 0.14, { BackgroundColor3 = BASE.panel }) end)
stopBtn.MouseButton1Click:Connect(function() panicStop() end)

-- ---------------------------------------------------------------- library tab
W.section(m1Win, pLib, "Saved moves")
libSearch = W.input(m1Win, pLib, { text = "Find", placeholder = "name or skill id" })
libCount = inst("TextLabel", {
    BackgroundTransparency = 1,
    Size = UDim2.new(1, 0, 0, 16),
    Font = FONT_MONO,
    TextSize = 11,
    TextColor3 = BASE.dim,
    TextXAlignment = Enum.TextXAlignment.Left,
    Text = #LIB.entries .. " saved",
    LayoutOrder = nextOrder(pLib),
}, pLib)

libList = W.vlist(m1Win, pLib, {
    height = 300,
    rowH = 30,
    text = function(e) return e.name .. "   ·   " .. e.id end,
    onRow = function(e) openDetail(e) end,
})

local libSearchToken = 0
libSearch:GetPropertyChangedSignal("Text"):Connect(function()
    libSearchToken += 1
    local t = libSearchToken
    task.delay(0.1, function()
        if t == libSearchToken then libRefresh() end
    end)
end)
libRefresh()

local libOverlay = inst(WIN_CLASS, {
    Position = UDim2.fromOffset(0, 84),
    Size = UDim2.new(1, 0, 1, -114),
    BackgroundColor3 = BASE.bg,
    BorderSizePixel = 0,
    ClipsDescendants = true,
    Visible = false,
    ZIndex = 8,
}, m1Win.frame)

local ovHead = inst("Frame", {
    Size = UDim2.new(1, 0, 0, 46),
    BackgroundColor3 = BASE.bg2,
    BorderSizePixel = 0,
    ZIndex = 9,
}, libOverlay)
local ovLine = inst("Frame", { Position = UDim2.new(0, 0, 1, -1), Size = UDim2.new(1, 0, 0, 1), BackgroundColor3 = BASE.line, BorderSizePixel = 0, ZIndex = 10 }, ovHead)
local detailTitle = inst("TextLabel", {
    BackgroundTransparency = 1,
    Position = UDim2.fromOffset(16, 5),
    Size = UDim2.new(1, -70, 0, 18),
    Font = FONT_MONO,
    TextSize = 14,
    TextColor3 = BASE.text,
    TextXAlignment = Enum.TextXAlignment.Left,
    Text = "",
    ZIndex = 10,
}, ovHead)
local detailSub = inst("TextLabel", {
    BackgroundTransparency = 1,
    Position = UDim2.fromOffset(16, 24),
    Size = UDim2.new(1, -70, 0, 14),
    Font = FONT_MONO,
    TextSize = 11,
    TextColor3 = BASE.dim,
    TextXAlignment = Enum.TextXAlignment.Left,
    Text = "",
    ZIndex = 10,
}, ovHead)
local ovClose = inst("TextButton", {
    AnchorPoint = Vector2.new(1, 0.5),
    Position = UDim2.new(1, -12, 0.5, 0),
    Size = UDim2.fromOffset(26, 26),
    BackgroundColor3 = BASE.panel,
    BorderSizePixel = 0,
    Text = "✕",
    Font = FONT_MONO,
    TextSize = 13,
    TextColor3 = BASE.dim,
    AutoButtonColor = false,
    ZIndex = 10,
}, ovHead)
corner(ovClose, 8)
outline(ovClose, 1.2)
ovClose.MouseEnter:Connect(function() tw(ovClose, 0.12, { TextColor3 = RED }) end)
ovClose.MouseLeave:Connect(function() tw(ovClose, 0.14, { TextColor3 = BASE.dim }) end)

local detailPage = inst("ScrollingFrame", {
    Position = UDim2.fromOffset(0, 46),
    Size = UDim2.new(1, 0, 1, -46),
    BackgroundTransparency = 1,
    BorderSizePixel = 0,
    ScrollBarThickness = 3,
    ScrollBarImageColor3 = BASE.line,
    AutomaticCanvasSize = Enum.AutomaticSize.Y,
    CanvasSize = UDim2.new(0, 0, 0, 0),
    ScrollingDirection = Enum.ScrollingDirection.Y,
    ZIndex = 8,
}, libOverlay)
pad(detailPage, 12, 6, 12, 12)
inst("UIListLayout", { Padding = UDim.new(0, 8), SortOrder = Enum.SortOrder.LayoutOrder }, detailPage)

local detailAccentBase = nil

local function clearPage(page)
    for _, c in ipairs(page:GetChildren()) do
        if not c:IsA("UIListLayout") and not c:IsA("UIPadding") then c:Destroy() end
    end
    page:SetAttribute("order", 0)
end

closeDetail = function()
    if not libOverlay.Visible then return end
    if libOverlay:IsA("CanvasGroup") then
        local t = tw(libOverlay, 0.14, { GroupTransparency = 1 }, Enum.EasingStyle.Quad, Enum.EasingDirection.In)
        t.Completed:Connect(function() libOverlay.Visible = false end)
    else
        libOverlay.Visible = false
    end
end

openDetail = function(e)
    clearPage(detailPage)
    if detailAccentBase then
        for i = #m1Win.onAccent, detailAccentBase + 1, -1 do
            m1Win.onAccent[i] = nil
        end
    end
    detailAccentBase = #m1Win.onAccent

    detailTitle.Text = e.name
    detailSub.Text = e.id
    buildSlotControls(detailPage, e.slot)
    W.section(m1Win, detailPage, "Manage")
    W.button(m1Win, detailPage, {
        text = "Delete from library",
        callback = function()
            removeFromLib(e)
            closeDetail()
            notify("deleted " .. e.name, RED)
        end,
    })

    detailPage.CanvasPosition = Vector2.new(0, 0)
    libOverlay.Visible = true
    if libOverlay:IsA("CanvasGroup") then
        libOverlay.GroupTransparency = 1
        tw(libOverlay, 0.18, { GroupTransparency = 0 }, Enum.EasingStyle.Quad)
    end
end

ovClose.MouseButton1Click:Connect(function() closeDetail() end)

local libIdx
for i, t in ipairs(m1Win.pages) do
    if t.page == pLib then libIdx = i end
end
TAB_HOOKS[#TAB_HOOKS + 1] = function(key, idx)
    if key == "m1" and idx ~= libIdx and libOverlay.Visible then closeDetail() end
end

refreshCapture()

W.slider(m1Win, pVisual, {
    text = "Motion smoothing",
    min = 0.6, max = 2.4, step = 0.05, value = MOTION,
    callback = function(v) MOTION = v end,
})
W.slider(m1Win, pVisual, {
    text = "Box transparency",
    min = 0, max = 1, step = 0.05, value = 0.75,
    callback = function(v)
        for _, s in pairs(M1.slots) do s.alpha = v end
    end,
})
W.section(m1Win, pVisual, "Box color")
local boxSwatches = inst("Frame", {
    Size = UDim2.new(1, 0, 0, 26),
    BackgroundTransparency = 1,
    LayoutOrder = nextOrder(pVisual),
}, pVisual)
for i, c in ipairs(SWATCHES) do
    local s = inst("TextButton", {
        Position = UDim2.fromOffset((i - 1) * 26, 0),
        Size = UDim2.fromOffset(22, 22),
        BackgroundColor3 = c,
        BorderSizePixel = 0,
        Text = "",
        AutoButtonColor = false,
    }, boxSwatches)
    corner(s, 5)
    outline(s, 1.2)
    s.MouseButton1Click:Connect(function()
        for _, slot in pairs(M1.slots) do
            slot.color = c
            if slot.box then slot.box.Color = c end
        end
    end)
end

W.section(m1Win, pColorM, "Theme")
W.colorPicker(m1Win, pColorM)
W.themeSaver(m1Win, pColorM)
W.styleTab(m1Win, pColorM)

-- ---------------------------------------------------------------- teleport window
local tpWin = makeWindow("tp", "Teleport", USE_EMOJI and "🌀" or "TP")

local pGuideT = tpWin:addTab("Guide")
local pCtrl   = tpWin:addTab("Control")
local pColorT = tpWin:addTab("Settings")
tpWin:selectTab(2)

TP.onStatus = function(msg) tpWin:status(msg) end

do
    W.section(tpWin, pGuideT, "Quick start")
    W.note(tpWin, pGuideT, "Open the page you need in this tab, press the Click torso button, then click your own torso. Turn True Six Eyes off first — its hitbox sits over your body and blocks the click. After that, click the spot you want to stand on, set the interval and start it.")
    W.section(tpWin, pGuideT, "1 · Pick who moves")
    W.note(tpWin, pGuideT, "Press Click torso · select player, then click your character's torso. If the click keeps missing, type the model name into Model and use Lock by name instead.")
    W.section(tpWin, pGuideT, "2 · Pick the spot")
    W.note(tpWin, pGuideT, "Press Click ground spot, then click the floor where you want to stand. The teleport starts on that click and re-applies the spot every Interval, so you stay there.")
    W.section(tpWin, pGuideT, "3 · Keep it steady")
    W.note(tpWin, pGuideT, "Each tick the script looks straight down under the spot and rests your feet on the closest ground, so you stop floating above it. H pauses and resumes, J stops and puts you back where you locked in.")
    W.section(tpWin, pGuideT, "Tips")
    W.note(tpWin, pGuideT, "Be careful where you aim: hitboxes and invisible walls can sit in front of the floor you are clicking, and the spot lands on whatever the click actually hits — sometimes a wall or a roof instead of the ground.")
    W.note(tpWin, pGuideT, "If a spot still misbehaves, aim at a flat, clearly visible patch of floor a step away from props and ledges.")
end


W.section(tpWin, pCtrl, "Target")
local tpNameBox = W.input(tpWin, pCtrl, { text = "Model", placeholder = "Name_Server" })
W.button(tpWin, pCtrl, {
    text = "Lock by name",
    callback = function()
        local f = playersFolder()
        local m = f and f:FindFirstChild(tpNameBox.Text)
        if not m then notify("no model named " .. tpNameBox.Text, RED) return end
        tpLock(m)
    end,
})
W.button(tpWin, pCtrl, {
    text = "Click torso · select player",
    extraOutline = true,
    callback = function() armPick(tpLock, "click a player") end,
})

W.section(tpWin, pCtrl, "Destination")
W.button(tpWin, pCtrl, {
    text = "Click ground spot",
    callback = function()
        if not TP.root then notify("lock a target first", RED) return end
        pendingDest = function(p) tpSetDest(p) end
        notify("click a spot", State.colors.tp.a)
    end,
})
W.button(tpWin, pCtrl, { text = "Start / stop (H)", callback = tpToggle })
W.button(tpWin, pCtrl, { text = "Reset position (J)", callback = tpReset })
W.slider(tpWin, pCtrl, {
    text = "Interval (s)", min = 0.02, max = 0.5, step = 0.01, value = 0.1,
    callback = function(v) TP.interval = v end,
})


W.section(tpWin, pColorT, "Theme")
W.colorPicker(tpWin, pColorT)
W.themeSaver(tpWin, pColorT)
W.styleTab(tpWin, pColorT)

-- ---------------------------------------------------------------- crate opener
do
    local NAMES = CRATE.names

    function CRATE.remoteRef()
        local comm = ReplicatedStorage:FindFirstChild("NetworkComm")
        local inv = comm and comm:FindFirstChild("InventoryService")
        return inv and inv:FindFirstChild("UseItem_Method")
    end

    function CRATE.nameFor(id)
        local hit = NAMES[id]
        if hit then return hit end
        local cfgs = ReplicatedStorage:FindFirstChild("Configs")
        local mod = cfgs and cfgs:FindFirstChild("ItemConfig")
        if mod then
            local ok, data = pcall(require, mod)
            if ok and type(data) == "table" then
                local src = type(data.Items) == "table" and data.Items or data
                local d = src[id]
                if type(d) == "table" then
                    local n = d.Name or d.DisplayName or d.Title
                    if type(n) == "string" and n ~= "" then
                        NAMES[id] = n
                        return n
                    end
                end
                local seen = 0
                for _, v in pairs(src) do
                    seen += 1
                    if seen > 4000 then break end
                    if type(v) == "table" then
                        local rid = v.Id or v.ID or v.Key or v.ItemId
                        if rid == id then
                            local n = v.Name or v.DisplayName or v.Title
                            if type(n) == "string" and n ~= "" then
                                NAMES[id] = n
                                return n
                            end
                        end
                    end
                end
            end
        end
        NAMES[id] = id
        return id
    end

    function CRATE.refresh()
        local out = {}
        for _, e in ipairs(CRATE.list) do out[#out + 1] = e end
        if CRATE.ui then CRATE.ui.set(out) end
        if CRATE.uiCount then CRATE.uiCount.Text = #CRATE.list .. " captured" end
    end

    function CRATE.add(id)
        if type(id) ~= "string" or id == "" then return end
        if CRATE.byId[id] then
            CRATE.refresh()
            return
        end
        local e = { id = id, name = id, rate = 1, acc = 0 }
        CRATE.byId[id] = e
        CRATE.list[#CRATE.list + 1] = e
        CRATE.refresh()
        task.defer(function()
            e.name = CRATE.nameFor(id)
            CRATE.refresh()
            notify("caught " .. e.name, State.colors.crate.a)
        end)
    end

    function CRATE.useOnce(id)
        if not id or id == "" then return false, "no id" end
        local r = CRATE.remoteRef()
        if not r then return false, "UseItem_Method missing" end
        local ok, err = pcall(function()
            if r:IsA("RemoteEvent") then
                r:FireServer(id, "UseSuperMax")
            else
                r:InvokeServer(id, "UseSuperMax")
            end
        end)
        if not ok then return false, tostring(err) end
        CRATE.sent += 1
        return true
    end

    function CRATE.stop()
        CRATE.running = false
        if CRATE.uiOpen then pcall(CRATE.uiOpen.set, false) end
    end

    function CRATE.tick(dt)
        if CRATE.running and CRATE.selected then
            local e = CRATE.selected
            local step = 1 / math.clamp(e.rate or 1, 1, 10)
            e.acc += dt
            while e.acc >= step do
                e.acc -= step
                if CRATE.inflight >= 4 then
                    e.acc = 0
                    break
                end
                CRATE.inflight += 1
                task.spawn(function()
                    local ok, err = CRATE.useOnce(e.id)
                    CRATE.inflight = math.max(CRATE.inflight - 1, 0)
                    if not ok then
                        CRATE.stop()
                        notify("crate use failed: " .. tostring(err), RED)
                    end
                end)
            end
        end
        local now = os.clock()
        if now - CRATE.at >= 0.2 then
            CRATE.at = now
            if CRATE.onStat then CRATE.onStat(CRATE.sent, CRATE.inflight) end
        end
    end

    function CRATE.installHook()
        if crateHook.installed then return true end
        if not (hookmetamethod and getnamecallmethod) then
            crateHook.err = "executor has no hookmetamethod"
            return false
        end
        local ok, err = pcall(function()
            local prev
            prev = hookmetamethod(game, "__namecall", function(self, ...)
                if CRATE.listening and self == CRATE.remoteRef() then
                    local okm, method = pcall(getnamecallmethod)
                    if okm and (method == "InvokeServer" or method == "FireServer") then
                        local ours = false
                        if checkcaller then
                            local cok, c = pcall(checkcaller)
                            ours = cok and c or false
                        end
                        if not ours then
                            local a1 = ...
                            if type(a1) == "string" then task.defer(CRATE.add, a1) end
                        end
                    end
                end
                return prev(self, ...)
            end)
            crateHook.prev = prev
        end)
        if not ok then
            crateHook.err = tostring(err)
            return false
        end
        crateHook.installed = true
        return true
    end

    function CRATE.uninstallHook()
        if not crateHook.installed then return true end
        local prev = crateHook.prev
        local restored = false
        if prev then
            restored = pcall(hookmetamethod, game, "__namecall", prev)
            if not restored and restorefunction then
                restored = pcall(restorefunction, prev)
            end
        end
        if not restored then
            crateHook.err = "could not restore __namecall"
            return false
        end
        crateHook.prev = nil
        crateHook.installed = false
        return true
    end

    function CRATE.stopListen()
        if not CRATE.listening then return true end
        CRATE.listening = false
        if CRATE.uiListen then pcall(CRATE.uiListen.set, false) end
        return CRATE.uninstallHook()
    end
end

local crateWin = makeWindow("crate", "Crate Opener 928167.inc", USE_EMOJI and "📦" or "CR")
local pCrates     = crateWin:addTab("Crates")
local pCrateGuide = crateWin:addTab("Guide")
local pCrateSet   = crateWin:addTab("Settings")
crateWin:selectTab(1)

W.section(crateWin, pCrates, "Capture")
W.note(crateWin, pCrates, "Open a crate once in game and it lands here with its config id and name. Every fire sends UseSuperMax, so the only setting is uses per second.")

local crateListen
crateListen = W.toggle(crateWin, pCrates, {
    text = "Listen for crate uses",
    value = false,
    callback = function(v)
        if not v then
            CRATE.listening = false
            local ok = CRATE.uninstallHook()
            notify(ok and "crate listener off · hook removed" or ("crate listener off · " .. tostring(crateHook.err)), ok and BASE.dim or RED)
            return
        end
        if ListenOn then
            ListenOn = false
            if listenToggle then pcall(listenToggle.set, false) end
            uninstallHook()
        end
        if CRATE.installHook() then
            CRATE.listening = true
            notify("listening for crate uses", State.colors.crate.a)
            crateWin:status("hook installed")
        else
            crateListen.set(false)
            notify("hook failed: " .. tostring(crateHook.err), RED)
            crateWin:status("hook failed")
        end
    end,
})
CRATE.uiListen = crateListen

local crateCount = inst("TextLabel", {
    BackgroundTransparency = 1,
    Size = UDim2.new(1, 0, 0, 16),
    Font = FONT_MONO,
    TextSize = 11,
    TextColor3 = BASE.dim,
    TextXAlignment = Enum.TextXAlignment.Left,
    Text = "0 captured",
    LayoutOrder = nextOrder(pCrates),
}, pCrates)
CRATE.uiCount = crateCount

local crateSelLbl = inst("TextLabel", {
    BackgroundTransparency = 1,
    Size = UDim2.new(1, 0, 0, 18),
    Font = FONT_MONO,
    TextSize = 12,
    TextColor3 = BASE.dim,
    TextXAlignment = Enum.TextXAlignment.Left,
    Text = "Selected: none",
    LayoutOrder = nextOrder(pCrates),
}, pCrates)

local crateRate
local crateOpenBtn

local crateList = W.vlist(crateWin, pCrates, {
    height = 200,
    rowH = 30,
    text = function(e)
        local r = math.floor((e.rate or 1) + 0.5)
        return (CRATE.selected == e and "> " or "") .. e.name .. "   ·   " .. e.id .. "   ·   " .. r .. "/s"
    end,
    paint = function(e, row)
        if CRATE.selected == e then
            row.TextColor3 = State.colors.crate.b
        elseif e.name == e.id then
            row.TextColor3 = BASE.dim
        end
    end,
    onRow = function(e)
        CRATE.selected = e
        crateSelLbl.Text = "Selected: " .. e.name .. "   ·   " .. e.id
        crateSelLbl.TextColor3 = State.colors.crate.a
        crateRate.set(e.rate or 1)
        crateList.refresh()
        crateWin:status("selected " .. e.name)
    end,
})
CRATE.ui = crateList

local crateStat = inst("TextLabel", {
    BackgroundTransparency = 1,
    Size = UDim2.new(1, 0, 0, 16),
    Font = FONT_MONO,
    TextSize = 11,
    TextColor3 = BASE.dim,
    TextXAlignment = Enum.TextXAlignment.Left,
    Text = "sent 0   ·   inflight 0",
    LayoutOrder = nextOrder(pCrates),
}, pCrates)
CRATE.onStat = function(sent, inflight)
    crateStat.Text = "sent " .. sent .. "   ·   inflight " .. inflight
end

crateOpenBtn = W.toggle(crateWin, pCrates, {
    text = "Open selected",
    value = false,
    callback = function(v)
        if v and not CRATE.selected then
            notify("click a captured crate first", RED)
            crateOpenBtn.set(false)
            return
        end
        CRATE.running = v
        if CRATE.selected then CRATE.selected.acc = 0 end
        crateWin:status(v and ("opening " .. CRATE.selected.name) or "paused")
    end,
})
CRATE.uiOpen = crateOpenBtn

crateRate = W.slider(crateWin, pCrates, {
    text = "Uses / sec", min = 1, max = 10, step = 1, value = 1,
    callback = function(v)
        if CRATE.selected then
            CRATE.selected.rate = v
            crateList.refresh()
        end
    end,
})

W.button(crateWin, pCrates, {
    text = "Use once now",
    callback = function()
        if not CRATE.selected then notify("click a captured crate first", RED) return end
        local ok, err = CRATE.useOnce(CRATE.selected.id)
        if ok then
            crateWin:status("used " .. CRATE.selected.name)
        else
            notify("use failed: " .. tostring(err), RED)
        end
    end,
})
W.button(crateWin, pCrates, {
    text = "Clear captures",
    callback = function()
        if CRATE.running then CRATE.stop() end
        CRATE.list, CRATE.byId, CRATE.selected = {}, {}, nil
        crateSelLbl.Text = "Selected: none"
        crateSelLbl.TextColor3 = BASE.dim
        CRATE.refresh()
        crateWin:status("captures cleared")
    end,
})

W.section(crateWin, pCrates, "Manual id")
local crateIdBox = W.input(crateWin, pCrates, { text = "Item id", placeholder = "074S558xB42q" })
W.button(crateWin, pCrates, {
    text = "Add id",
    callback = function()
        local id = string.gsub(crateIdBox.Text or "", "%s", "")
        if id == "" then notify("type an id first", RED) return end
        CRATE.add(id)
        crateWin:status("added " .. id)
    end,
})

do
    W.section(crateWin, pCrateGuide, "Quick start")
    W.note(crateWin, pCrateGuide, "Turn Listen on, open one crate in game, then it appears in the list with its name and config id. Click it, set uses per second, turn Open on.")
    W.section(crateWin, pCrateGuide, "1 · Listen")
    W.note(crateWin, pCrateGuide, "On the Crates page, turn Listen for crate uses on. That puts one temporary hook on the UseItem remote; the M1 listener switches off while it runs, because only one hook can sit on the remote layer at a time.")
    W.section(crateWin, pCrateGuide, "2 · Open the crate once")
    W.note(crateWin, pCrateGuide, "Use the crate normally in game. The id it sends lands in the list, and the name is looked up from ReplicatedStorage.Configs.ItemConfig when the game exposes it.")
    W.section(crateWin, pCrateGuide, "3 · Pick it")
    W.note(crateWin, pCrateGuide, "Click the row. The line under the list shows the exact name and id that will be sent, and the row keeps its own uses per second.")
    W.section(crateWin, pCrateGuide, "4 · Fire it")
    W.note(crateWin, pCrateGuide, "Uses / sec starts at 1 and tops out at 10. Turn Open selected on to keep firing. Every request sends UseSuperMax, so there is no quantity to set.")
    W.section(crateWin, pCrateGuide, "Tips")
    W.note(crateWin, pCrateGuide, "If a crate never shows up, check that Listen is still on — turning the M1 listener on takes the hook back and switches the crate listener off.")
    W.note(crateWin, pCrateGuide, "If a use fails the opener stops itself instead of hammering the remote, and the reason shows in the status bar.")
    W.note(crateWin, pCrateGuide, "Already know the id? Paste it into Item id and press Add id to fire it without opening one first.")
end

W.section(crateWin, pCrateSet, "Theme")
W.colorPicker(crateWin, pCrateSet)
W.themeSaver(crateWin, pCrateSet)
W.styleTab(crateWin, pCrateSet)

CRATE.refresh()

-- ---------------------------------------------------------------- data tab
do
    local function killLibSlots()
        for _, e in ipairs(LIB.entries) do
            if e.slot.box then pcall(function() e.slot.box:Destroy() end) end
        end
        LIB.entries, LIB.byId = {}, {}
        for k in pairs(M1.slots) do
            if string.sub(k, 1, 4) == "lib:" then M1.slots[k] = nil end
        end
    end

    local function wipePlaceMoves()
        killLibSlots()
        libSave(false)
        libRefresh()
        refreshCapture()
    end

    local function wipeAllMoves()
        killLibSlots()
        pcall(function()
            if delfile and isfile and isfile(LIB_FILE) then delfile(LIB_FILE) end
        end)
        libRefresh()
        refreshCapture()
    end

    local function wipeSettings()
        pcall(function()
            if delfile and isfile and isfile(CONFIG_FILE) then delfile(CONFIG_FILE) end
        end)
        for k, v in pairs(STYLE_DEFAULT.bg) do STYLE.bg[k] = v end
        for k, v in pairs(STYLE_DEFAULT.image) do STYLE.image[k] = v end
        STYLE.opacity = STYLE_DEFAULT.opacity
        STYLE.scan    = STYLE_DEFAULT.scan
        STYLE.glow    = STYLE_DEFAULT.glow
        STYLE.round   = STYLE_DEFAULT.round
        STYLE.outline = STYLE_DEFAULT.outline
        STYLE.scale   = STYLE_DEFAULT.scale
        STYLE.imgTrans = STYLE_DEFAULT.imgTrans
        STYLE.imgFit   = STYLE_DEFAULT.imgFit
        for k, st in pairs(State.colors) do
            local d = THEMES[k]
            if d then st.a, st.b = d.a, d.b end
        end
        for _, w in pairs(WINDOWS) do w:refreshAccent() end
        refreshRailColors()
        applyAllStyles()
    end

    local function wipeCaptures()
        Capture.list, Capture.byId = {}, {}
        refreshCapture()
    end

    for _, key in ipairs(MODULE_ORDER) do
        local win = WINDOWS[key]
        if win then
            local page = win:addTab("Data")
            W.section(win, page, "Saved data")
            W.note(win, page, "Two files: " .. CONFIG_FILE .. " holds themes, style and backgrounds. " .. LIB_FILE .. " holds saved moves for every place.")
            W.button(win, page, {
                text = "Wipe this place's moves",
                callback = function()
                    wipePlaceMoves()
                    notify("place moves wiped", RED)
                end,
            })
            W.button(win, page, {
                text = "Wipe all saved moves",
                callback = function()
                    wipeAllMoves()
                    notify("all saved moves wiped", RED)
                end,
            })
            W.button(win, page, {
                text = "Wipe settings, theme, backgrounds",
                callback = function()
                    wipeSettings()
                    notify("settings reset to defaults", RED)
                end,
            })
            W.button(win, page, {
                text = "Clear captures",
                callback = function()
                    wipeCaptures()
                    notify("captures cleared", RED)
                end,
            })

            W.section(win, page, "Everything")
            W.button(win, page, {
                text = "Stop everything  ·  keep UI",
                callback = function()
                    pcall(panicStop)
                    notify("all features stopped", RED)
                end,
            })
            W.button(win, page, {
                text = "WIPE ALL DATA  ·  then unload UI",
                callback = function()
                    wipeAllMoves()
                    wipeSettings()
                    wipeCaptures()
                    pcall(panicStop)
                    if doUnload then doUnload() end
                end,
            })
        end
    end
end

-- ---------------------------------------------------------------- rail
local railButtons = {}

local function makeRailButton(key, symbol, offsetY)
    local shownX, hiddenX = -RAIL_OFF, 96
    local shownC, hiddenC = shownX - RAIL_W * 0.5, hiddenX - RAIL_W * 0.5

    local glow = inst("Frame", {
        AnchorPoint = Vector2.new(0.5, 0.5),
        Position = UDim2.new(1, hiddenC, 0.5, offsetY),
        Size = UDim2.fromOffset(RAIL_W + 18, RAIL_W + 18),
        BackgroundColor3 = State.colors[key].a,
        BackgroundTransparency = 0.88,
        BorderSizePixel = 0,
        Active = false,
    }, gui)
    corner(glow, 20)
    HALOS[#HALOS + 1] = glow

    local b = inst("TextButton", {
        AnchorPoint = Vector2.new(1, 0.5),
        Position = UDim2.new(1, hiddenX, 0.5, offsetY),
        Size = UDim2.fromOffset(RAIL_W, RAIL_W),
        BackgroundColor3 = BASE.panel,
        BorderSizePixel = 0,
        Text = "",
        AutoButtonColor = false,
    }, gui)
    corner(b, 14)
    outline(b, 1.6)

    local tint = inst("Frame", { Size = UDim2.fromScale(1, 1), BackgroundColor3 = Color3.new(1, 1, 1), BorderSizePixel = 0 }, b)
    corner(tint, 14)
    local grad = inst("UIGradient", {
        Rotation = 120,
        Color = ColorSequence.new(State.colors[key].a, State.colors[key].b),
        Transparency = NumberSequence.new(0.6),
    }, tint)

    inst("TextLabel", {
        BackgroundTransparency = 1,
        Size = UDim2.fromScale(1, 1),
        Font = FONT_MONO,
        TextSize = 22,
        TextColor3 = Color3.fromRGB(255, 255, 255),
        Text = symbol,
    }, b)

    railButtons[key] = {
        btn = b, glow = glow, grad = grad,
        shown = UDim2.new(1, shownX, 0.5, offsetY),
        hidden = UDim2.new(1, hiddenX, 0.5, offsetY),
        gshown = UDim2.new(1, shownC, 0.5, offsetY),
        ghidden = UDim2.new(1, hiddenC, 0.5, offsetY),
    }

    b.MouseEnter:Connect(function()
        tw(b, 0.15, { Size = UDim2.fromOffset(RAIL_W + 4, RAIL_W + 4) }, Enum.EasingStyle.Quint)
        tw(grad, 0.15, { Transparency = NumberSequence.new(0.38) })
        tw(glow, 0.15, { BackgroundTransparency = 0.7 })
    end)
    b.MouseLeave:Connect(function()
        tw(b, 0.15, { Size = UDim2.fromOffset(RAIL_W, RAIL_W) }, Enum.EasingStyle.Quint)
        tw(grad, 0.15, { Transparency = NumberSequence.new(0.6) })
        tw(glow, 0.15, { BackgroundTransparency = 0.88 })
    end)
    b.MouseButton1Click:Connect(function()
        if State.open == key then closeActive() else openWindow(key) end
    end)
end

local RAIL_ICONS = {
    m1    = USE_EMOJI and "👊" or "M1",
    tp    = USE_EMOJI and "🌀" or "TP",
    crate = USE_EMOJI and "📦" or "CR",
}
for _, key in ipairs(MODULE_ORDER) do
    makeRailButton(key, RAIL_ICONS[key] or "?", moduleOffset(key))
end

local badgeShow
do
    local COL = Color3.fromRGB(90, 170, 255)
    local TXT = "(BUILD 1.0)"

    local lbl = inst("TextLabel", {
        AnchorPoint = Vector2.new(1, 0),
        Position = UDim2.new(1, -18, 0, 8),
        Size = UDim2.fromOffset(430, 46),
        BackgroundTransparency = 1,
        Font = FONT_TITLE,
        TextSize = 34,
        TextColor3 = COL,
        TextTransparency = 1,
        TextXAlignment = Enum.TextXAlignment.Right,
        TextYAlignment = Enum.TextYAlignment.Top,
        Text = TXT,
        Visible = false,
    }, gui)

    badgeShow = function(show)
        if show then
            lbl.Visible = true
            lbl.Position = UDim2.new(1, -18, 0, 2)
            tw(lbl, 0.3, { TextTransparency = 0 })
            tw(lbl, 0.3, { Position = UDim2.new(1, -18, 0, 8) }, Enum.EasingStyle.Quint)
        else
            local t = tw(lbl, 0.2, { TextTransparency = 1 })
            t.Completed:Connect(function()
                if lbl.TextTransparency > 0.9 then lbl.Visible = false end
            end)
        end
    end
end

function refreshRailColors()
    for key, e in pairs(railButtons) do
        e.grad.Color = ColorSequence.new(State.colors[key].a, State.colors[key].b)
        e.glow.BackgroundColor3 = State.colors[key].a
    end
end

local function setRail(open)
    State.railOpen = open
    badgeShow(open)
    for i, key in ipairs(MODULE_ORDER) do
        local e = railButtons[key]
        task.delay((i - 1) * 0.05, function()
            if not e.btn.Parent then return end
            tw(e.btn, 0.32, { Position = open and e.shown or e.hidden }, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
            tw(e.glow, 0.32, { Position = open and e.gshown or e.ghidden }, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
        end)
    end
end

for _, e in pairs(railButtons) do
    e.btn.Position = e.hidden
    e.glow.Position = e.ghidden
end

applyAllStyles()

-- ---------------------------------------------------------------- input
track(UIS.InputBegan:Connect(function(input, gpe)
    if input.KeyCode == TOGGLE_KEY and not gpe then
        if State.railOpen then
            setRail(false)
            closeActive()
        else
            setRail(true)
        end
        return
    end

    if gpe then return end

    if input.KeyCode == Enum.KeyCode.H then
        if not TP.root or not TP.root.Parent then
            armPick(tpLock, "click a player")
        elseif not TP.dest then
            pendingDest = function(p) tpSetDest(p) end
            notify("click a spot", State.colors.tp.a)
        else
            tpToggle()
        end
        return
    end

    if input.KeyCode == Enum.KeyCode.J then
        tpReset()
        return
    end

    if input.UserInputType == Enum.UserInputType.MouseButton1 then
        if pendingDest then
            local p = aimPoint()
            local cb = pendingDest
            pendingDest = nil
            if p then cb(p) end
            return
        end
        if pendingPick then
            local t = Mouse.Target
            if not t then return end
            local f = playersFolder()
            local m = t
            while m and m.Parent do
                if m.Parent == f then break end
                m = m.Parent
            end
            if not m or not m.Parent or m.Parent ~= f then
                notify("not a player character", RED)
                return
            end
            local cb = pendingPick
            pendingPick = nil
            if rootOf(m) then cb(m) else notify("no root on " .. m.Name, RED) end
        end
    end
end))

-- ---------------------------------------------------------------- heartbeat
track(RunService.Heartbeat:Connect(function(dt)
    if TP.running and TP.dest then
        TP.acc += dt
        if TP.acc >= TP.interval then
            TP.acc = 0
            if not TP.root or not TP.root.Parent then
                local f = playersFolder()
                local m = f and TP.name and f:FindFirstChild(TP.name)
                local r = m and rootOf(m)
                if r then
                    TP.root = r
                else
                    TP.running = false
                    tpSay("target gone", RED)
                end
            end
            if TP.root and TP.root.Parent and TP.dest then
                local model = TP.root.Parent
                if not TP.lift then
                    local minY, baseY = math.huge, TP.root.Position.Y
                    for _, d in ipairs(model:GetDescendants()) do
                        if d:IsA("BasePart") and d ~= TP.root then
                            local b = d.Position.Y - d.Size.Y * 0.5
                            if b < minY then minY = b end
                        end
                    end
                    TP.lift = (minY < math.huge) and math.clamp(baseY - minY, 0.5, 12) or 3
                end
                local rp = RaycastParams.new()
                rp.FilterType = Enum.RaycastFilterType.Exclude or Enum.RaycastFilterType.Blacklist
                pcall(function() rp.RespectCanCollide = true end)
                local filter = { model }
                local mine = LP.Character
                if mine and mine ~= model then filter[#filter + 1] = mine end
                rp.FilterDescendantsInstances = filter
                local from = Vector3.new(TP.dest.X, TP.dest.Y + 10, TP.dest.Z)
                local ground = Workspace:Raycast(from, Vector3.new(0, -400, 0), rp)
                local y = ground and (ground.Position.Y + TP.lift) or TP.dest.Y
                local c = TP.root.CFrame
                TP.root.CFrame = CFrame.new(TP.dest.X, y, TP.dest.Z) * (c - c.Position)
                TP.root.AssemblyLinearVelocity = Vector3.zero
                TP.root.AssemblyAngularVelocity = Vector3.zero
            end
        end
    end

    for _, slot in pairs(M1.slots) do
        runSlot(slot, dt)
    end
    runMoves(dt)
    if CRATE.tick then CRATE.tick(dt) end
end))

-- ---------------------------------------------------------------- teardown
local unloaded = false

doUnload = function()
    if unloaded then return end
    unloaded = true

    ListenOn = false
    pcall(uninstallHook)

    TP.running = false
    TP.dest = nil
    pendingPick, pendingDest = nil, nil

    M1.moves.enabled = false
    CRATE.running = false
    CRATE.listening = false
    pcall(CRATE.uninstallHook)
    for _, slot in pairs(M1.slots) do
        slot.enabled = false
        if slot.box then pcall(function() slot.box:Destroy() end); slot.box = nil end
    end

    for _, c in ipairs(CONNS) do pcall(function() c:Disconnect() end) end
    table.clear(CONNS)

    if getgenv().OJBS_Cleanup == doUnload then getgenv().OJBS_Cleanup = nil end
    pcall(function() gui:Destroy() end)
    print("[OJBS] unloaded — remotes restored, gui destroyed")
end

getgenv().OJBS_Cleanup = doUnload

--normal
Executor compatibility changes over time. Check current reports before testing.

Note: Every script shared here is personally tested on MacSploit first to keep things safe and working for you.

How to use these scripts?

You simply follow these quick steps given below to get the script running in the Jujutsu: Zero Roblox game.

  • Download a Script Executor – I only recommend Hydrogen, AWP.GG, Delta, Fluxus, or Codex.
  • Attach the Executor – Open the executor and connect it to your Roblox game process.
  • Paste the Script – Copy the code above and paste it into the executor.
  • Activate Features – Click the Execute button so the script injects and features will activate automatically.

Game Details:

  • Name: Jujutsu: Zero
  • Developer: Studio Resonance
  • Maturity: Mild (Age 5+)
  • Genre: Action
  • Subgenre: Open World Action

Frequently Asked Questions

What is a Jujutsu Zero script?

A Jujutsu Zero script is third-party Lua code intended to run alongside the Roblox game through a compatible script executor.

What features does this Jujutsu Zero script include?

Different scripts contain different code. This version includes: Auto Farm, Auto Raid, Auto Spin, enjoy!, dc: waitwhatismyuser.

How do you use the Jujutsu Zero script?

Pick a compatible executor such as Hydrogen, MacSploit, AWP.GG, Delta, Fluxus, Codex, launch Roblox and join the game, copy the complete Lua code from the script card above, paste it into the executor’s editor, and click Run or Execute. Compatibility changes over time, so a name here doesn’t guarantee current support.

Can a Jujutsu Zero script get your Roblox account banned?

Yes. Third-party scripts can violate Roblox rules and may put an account at risk. Only use code from a source you trust, never enter your Roblox password into a script or executor, and test on an alternate account first.

Does the Jujutsu Zero script work on mobile?

Check whether both the executor and the script support your device and the current Roblox version. Mobile executor support does not guarantee that every script will work.

Check out our Roblox Scripts hub and Roblox Games Directory for more.