Uma Racing Script Roblox | Infinite Stamina

PUBLISHEDUPDATED
What changed
  • 2026-11-15 — Added Script #2: Infinite Stamina & More.
Verified Working1 Active Script100% Free

If you’re hunting for Uma Racing scripts and tired of scrolling through half-baked links and expired Pastebins, you can relax because everything you need is available here.

 We’ve functional scripts for Uma Racing which can unlock pro features for you with minimal friction.

Script Features:

  • Infinite Stamina – Free infinite stamina trick for every race

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.

Uma Racing Script:

Working ScriptFree
game:GetService("StarterGui"):SetCore("SendNotification", {
    Title = "More Open Source Script",
    Text = "For Join: https://discord.gg/URmka8WnQ5",
    Duration = 5
})

local Lib = loadstring(game:HttpGet("https://raw.githubusercontent.com/bloodball/-back-ups-for-libs/main/turtle"))()
local Win = Lib:Window("DraWatX Open Source")

local FVelocity = Vector3.new(0, 0, 0)
local ECSetting = false
local ISSetting = false
local VMSetting = 1

Win:Toggle("Easy Control", false, function(Bool)
    ECSetting = Bool
end)

Win:Toggle("Infinity Stamina", false, function(Bool)
    ISSetting = Bool
end)

Win:Slider("Velocity Multiplier", 1, 4, 1, function(Value)
    VMSetting = Value
end)

Win:Button("Discord Link", function()
    setclipboard("https://discord.gg/URmka8WnQ5")
end)

local oldindex;oldindex = hookmetamethod(game, "__index", function(v1, v2)
    if ECSetting and v2 == "Velocity" and getnamecallmethod() == "ToOrientation" then
        return FVelocity
    end
    return oldindex(v1, v2)
end)

local oldnewindex;oldnewindex = hookmetamethod(game, "__newindex", function(v1, v2, v3)
    if v2 == "AssemblyLinearVelocity" then
        if math.abs((v3 * VMSetting).Magnitude) < 700 then
            return oldnewindex(v1, v2, v3 * VMSetting)
        end
        return oldnewindex(v1, v2, FVelocity)
    end
    return oldnewindex(v1, v2, v3)
end)

local oldnamecall;oldnamecall = hookmetamethod(game, "__namecall", function(v1, v2, ...)
    if ISSetting and getnamecallmethod() == "FireServer" and v2 == "SpeedTarget" then
        return oldnamecall(v1, v2, 0)
    end
    return oldnamecall(v1, v2, ...)
end)
Compatible executors: HydrogenMacSploitAWP.GGDelta

Script #2 Infinite Stamina & More

Script #2 · Infinite Stamina & MoreFree
Infinite StaminaAuto QTESpeed ModiferQTE Promt ClickFullbrightAnti AFK
-- RAKAUSUME | UmaRacing Exploit Kit v18
-- Perfected: bugfixes + real Infinite Boost + toggle refs + stamina harden

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local TweenService = game:GetService("TweenService")
local CoreGui = game:GetService("CoreGui")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ReplicatedFirst = game:GetService("ReplicatedFirst")
local Lighting = game:GetService("Lighting")
local VirtualUser = game:GetService("VirtualUser")
local VIM = game:GetService("VirtualInputManager")

local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local rootPart = character:WaitForChild("HumanoidRootPart")
local camera = workspace.CurrentCamera

-- ============================================
-- THEME
-- ============================================
local THEME = {
    Bg        = Color3.fromRGB(6, 6, 12),
    Bg2       = Color3.fromRGB(12, 12, 20),
    Bg3       = Color3.fromRGB(18, 18, 28),
    Bg4       = Color3.fromRGB(26, 26, 40),
    Bg5       = Color3.fromRGB(36, 36, 54),
    Stroke    = Color3.fromRGB(50, 50, 78),
    StrokeLt  = Color3.fromRGB(80, 80, 120),
    Accent    = Color3.fromRGB(155, 95, 255),
    Accent2   = Color3.fromRGB(95, 175, 255),
    Text      = Color3.fromRGB(240, 240, 252),
    TextDim   = Color3.fromRGB(135, 135, 172),
    TextDim2  = Color3.fromRGB(90, 90, 122),
    Green     = Color3.fromRGB(95, 255, 155),
    Yellow    = Color3.fromRGB(255, 210, 100),
    Red       = Color3.fromRGB(255, 95, 125),
    Orange    = Color3.fromRGB(255, 140, 60),
    Glass     = Color3.fromRGB(255, 255, 255),
}

local ACCENT_PRESETS = {
    Purple = {main = Color3.fromRGB(155, 95, 255), alt = Color3.fromRGB(95, 175, 255)},
    Cyan   = {main = Color3.fromRGB(95, 200, 255), alt = Color3.fromRGB(70, 240, 220)},
    Pink   = {main = Color3.fromRGB(255, 95, 180), alt = Color3.fromRGB(200, 95, 255)},
    Green  = {main = Color3.fromRGB(95, 240, 130), alt = Color3.fromRGB(60, 200, 180)},
    Orange = {main = Color3.fromRGB(255, 150, 80), alt = Color3.fromRGB(255, 95, 130)},
    Red    = {main = Color3.fromRGB(255, 80, 110), alt = Color3.fromRGB(255, 140, 60)},
}

-- ============================================
-- CHARACTER DATABASE
-- ============================================
local CHARACTERS = {
    ["rice shower"] = "Rice Shower",
    ["neo universe"] = "Neo Universe",
    ["oguri cap"] = "Oguri Cap",
    ["oguri mastery"] = "Oguri Mastery",
    ["tamamo cross"] = "Tamamo Cross",
    ["silence suzuka"] = "Silence Suzuka",
    ["tokai teio"] = "Tokai Teio",
    ["tm opera o"] = "TM Opera O",
    ["yaeno muteki"] = "Yaeno Muteki",
    ["mejiro mcqueen"] = "Mejiro McQueen",
    ["super creek"] = "Super Creek",
    ["meisho doto"] = "Meisho Doto",
    ["gold ship"] = "Gold Ship",
    ["daiwa scarlet"] = "Daiwa Scarlet",
    ["air groove"] = "Air Groove",
    ["nice nature"] = "Nice Nature",
    ["haru urara"] = "Haru Urara",
}
local HARDEST_CHAR = "oguri mastery"

-- ============================================
-- WALLPAPER
-- ============================================
local WALLPAPER_STATE = { unlocked = false, current = "default" }
local WALLPAPERS = { default = nil, oguri1 = nil, oguri2 = nil, oguri3 = nil }
local wallRefs = {}

-- ============================================
-- CONFIG
-- ============================================
local CONFIG = {
    AutoQTE = false,
    QTERate = 0.01,
    QTEUsePromptClick = true,
    InfiniteStamina = false,
    SpeedBoost = false,
    InfiniteBoost = false,
    SpeedMultiplier = 2.5,
    Fullbright = false,
    PlayerESP = false,
    ESPRGBBorder = false,
    AntiAFK = false,
    AntiKick = false,
    AntiStaff = false,
    DeepStamScan = true,
    UITransparency = 0,
    AccentName = "Purple",
    AccentColor = THEME.Accent,
    AccentAlt = THEME.Accent2,
    KeybindStamina = Enum.KeyCode.Z,
    KeybindMenu = Enum.KeyCode.RightShift,
}

local staminaToggleCardRef = nil
local espToggleCardRef = nil
local speedToggleCardRef = nil
local qteToggleCardRef = nil

-- ============================================
-- UTIL
-- ============================================
local function corner(o, r) local c=Instance.new("UICorner"); c.CornerRadius=UDim.new(0,r or 8); c.Parent=o; return c end
local function stroke(o, c, t, tr)
    local s=Instance.new("UIStroke"); s.Color=c or THEME.Stroke; s.Thickness=t or 1
    s.Transparency=tr or 0.3; s.ApplyStrokeMode=Enum.ApplyStrokeMode.Border; s.Parent=o; return s
end
local function grad(o, c1, c2, rot)
    local g=Instance.new("UIGradient"); g.Color=ColorSequence.new(c1, c2); g.Rotation=rot or 0; g.Parent=o; return g
end
local function pad(o, t, b, l, r)
    local p=Instance.new("UIPadding")
    p.PaddingTop=UDim.new(0,t or 0); p.PaddingBottom=UDim.new(0,b or 0)
    p.PaddingLeft=UDim.new(0,l or 0); p.PaddingRight=UDim.new(0,r or 0)
    p.Parent=o; return p
end
local function list(o, gap, dir)
    local l=Instance.new("UIListLayout"); l.Padding=UDim.new(0,gap or 6)
    l.FillDirection=dir or Enum.FillDirection.Vertical
    l.SortOrder=Enum.SortOrder.LayoutOrder; l.Parent=o; return l
end
local function tween(o, t, props)
    local tw=TweenService:Create(o, TweenInfo.new(t or 0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), props)
    tw:Play(); return tw
end
local function shadow(o, color, thickness, transp)
    local s = Instance.new("UIStroke")
    s.Color = color or Color3.fromRGB(0,0,0)
    s.Thickness = thickness or 2
    s.Transparency = transp or 0.8
    s.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
    s.Parent = o
    return s
end

-- ============================================
-- NOTIFICATIONS
-- ============================================
local notifHolder
local notifQueue = {}

local function notify(text, kind, dur)
    kind = kind or "info"; dur = dur or 3
    if not notifHolder then return end
    local color = kind=="success" and THEME.Green
        or kind=="error" and THEME.Red
        or kind=="warn" and THEME.Yellow
        or kind=="hardest" and THEME.Orange
        or CONFIG.AccentColor
    local icon = kind=="success" and "✓"
        or kind=="error" and "✕"
        or kind=="warn" and "!"
        or kind=="hardest" and "★"
        or "i"
    local n = Instance.new("Frame")
    n.Size = UDim2.new(0, 290, 0, 56)
    n.BackgroundColor3 = THEME.Bg2
    n.BackgroundTransparency = 0.05
    n.BorderSizePixel = 0
    n.Parent = notifHolder
    n.ZIndex = 60
    corner(n, 12)
    stroke(n, color, 1.2, 0.3)
    shadow(n, Color3.fromRGB(0,0,0), 3, 0.7)
    local bar = Instance.new("Frame")
    bar.Size = UDim2.new(0, 3, 1, 0)
    bar.BackgroundColor3 = color
    bar.BorderSizePixel = 0
    bar.ZIndex = 61
    bar.Parent = n
    corner(bar, 3)
    local ic = Instance.new("Frame")
    ic.Size = UDim2.new(0, 26, 0, 26)
    ic.Position = UDim2.new(0, 12, 0.5, -13)
    ic.BackgroundColor3 = color
    ic.BackgroundTransparency = 0.75
    ic.ZIndex = 61
    ic.Parent = n
    corner(ic, 13)
    local icLbl = Instance.new("TextLabel")
    icLbl.Size = UDim2.new(1, 0, 1, 0)
    icLbl.BackgroundTransparency = 1
    icLbl.Text = icon
    icLbl.TextColor3 = color
    icLbl.TextSize = 14
    icLbl.Font = Enum.Font.GothamBold
    icLbl.ZIndex = 62
    icLbl.Parent = ic
    local lbl = Instance.new("TextLabel")
    lbl.Size = UDim2.new(1, -50, 0, 34)
    lbl.Position = UDim2.new(0, 46, 0, 8)
    lbl.BackgroundTransparency = 1
    lbl.Text = text
    lbl.TextColor3 = THEME.Text
    lbl.TextSize = 12
    lbl.Font = Enum.Font.Gotham
    lbl.TextXAlignment = Enum.TextXAlignment.Left
    lbl.TextYAlignment = Enum.TextYAlignment.Top
    lbl.TextWrapped = true
    lbl.ZIndex = 61
    lbl.Parent = n
    local pTrack = Instance.new("Frame")
    pTrack.Size = UDim2.new(1, -58, 0, 2)
    pTrack.Position = UDim2.new(0, 46, 1, -14)
    pTrack.BackgroundColor3 = THEME.Bg4
    pTrack.BorderSizePixel = 0
    pTrack.ZIndex = 61
    pTrack.Parent = n
    corner(pTrack, 1)
    local pFill = Instance.new("Frame")
    pFill.Size = UDim2.new(1, 0, 1, 0)
    pFill.BackgroundColor3 = color
    pFill.BorderSizePixel = 0
    pFill.ZIndex = 62
    pFill.Parent = pTrack
    corner(pFill, 1)
    tween(pFill, dur, {Size = UDim2.new(0, 0, 1, 0)})

    n.Position = UDim2.new(1, 20, 0, #notifQueue * 64)
    tween(n, 0.35, {Position = UDim2.new(1, -310, 0, #notifQueue * 64)})
    table.insert(notifQueue, n)
    task.delay(dur, function()
        tween(n, 0.3, {Position = UDim2.new(1, 20, 0, n.Position.Y.Offset)})
        task.wait(0.3)
        for i, v in ipairs(notifQueue) do if v == n then table.remove(notifQueue, i) break end end
        n:Destroy()
        for i, v in ipairs(notifQueue) do
            tween(v, 0.2, {Position = UDim2.new(1, -310, 0, (i-1)*64)})
        end
    end)
end

-- ============================================
-- DEEP STAMINA SCAN (gc + remote sniffer)
-- ============================================
local staminaCache = {} -- [player] = {value=, max=, lastUpdate=}

-- remote sniffer: capture numbers flying through remotes and match to players
local function startRemoteSniffer()
    task.spawn(function()
        for _, obj in pairs(ReplicatedStorage:GetDescendants()) do
            if obj:IsA("RemoteEvent") then
                pcall(function()
                    obj.OnClientEvent:Connect(function(...)
                        local args = {...}
                        for _, v in ipairs(args) do
                            if type(v) == "table" then
                                -- sometimes the payload is a table {player=, stamina=}
                                local plr = v.player or v.Player or v.plr or v.who
                                local stam = v.stamina or v.Stamina or v.energy or v.Energy or v.sp or v.SP
                                local max = v.max or v.Max or v.maxStamina or v.MaxStamina
                                if plr and (plr:IsA("Player")) and type(stam) == "number" then
                                    local maxv = tonumber(max) or 100
                                    staminaCache[plr] = {value = stam, max = maxv, lastUpdate = tick()}
                                end
                            elseif type(v) == "number" and v >= 0 and v <= 100 then
                                -- raw number broadcast — attribute to no one specific, skip
                            end
                        end
                    end)
                end)
            end
        end
    end)
end

-- getgc scanner: walks all gc objects for stamina-looking NumberValues
-- this catches instances the game keeps in memory but not in the DataModel
local function gcScanStamina(plr)
    if not getgc then return nil end
    local best = nil
    pcall(function()
        for _, obj in pairs(getgc(true)) do
            if type(obj) == "table" then
                -- check tables with userdata/value keys
                local potential = nil
                for k, v in pairs(obj) do
                    if type(k) == "string" then
                        local lk = k:lower()
                        if lk:find("stamina") or lk:find("energy") then
                            if type(v) == "number" and v >= 0 and v <= 1000 then
                                potential = v
                            end
                        end
                    end
                end
                if potential and not best then
                    best = potential
                end
            end
        end
    end)
    return best
end

-- public: get stamina % for a player, tries all methods
local function getPlayerStaminaPercent(plr)
    local char = plr.Character
    if not char then return nil end

    -- 1. cached from remote sniffer (freshest, most likely correct)
    local cached = staminaCache[plr]
    if cached and tick() - cached.lastUpdate < 5 then
        if cached.max and cached.max > 0 then
            return math.clamp(math.floor((cached.value / cached.max) * 100), 0, 100)
        end
    end

    -- 2. leaderstats
    local ls = plr:FindFirstChild("leaderstats")
    if ls then
        local cur, max
        for _, obj in pairs(ls:GetChildren()) do
            local n = obj.Name:lower()
            if n:find("stamina") or n:find("energy") or n:find("endur") then
                if n:find("max") then max = obj.Value
                else cur = obj.Value end
            end
        end
        if cur then
            if not max or max <= 0 then max = 100 end
            return math.clamp(math.floor((cur/max)*100), 0, 100)
        end
    end

    -- 3. player attributes
    local curAttr, maxAttr
    for attr, val in pairs(plr:GetAttributes()) do
        if type(val) == "number" then
            local n = attr:lower()
            if n:find("stamina") or n:find("energy") or n:find("endur") then
                if n:find("max") then maxAttr = val
                else curAttr = val end
            end
        end
    end
    if curAttr then
        if not maxAttr or maxAttr <= 0 then maxAttr = 100 end
        return math.clamp(math.floor((curAttr/maxAttr)*100), 0, 100)
    end

    -- 4. char children
    local cur, max = nil, nil
    for _, obj in pairs(char:GetChildren()) do
        if obj:IsA("NumberValue") or obj:IsA("IntValue") then
            local n = obj.Name:lower()
            if n:find("stamina") or n:find("energy") or n:find("endur") then
                if n:find("max") then max = max or obj.Value
                else cur = cur or obj.Value end
            end
        end
    end

    -- 5. deep descendant scan
    if not cur then
        for _, obj in pairs(char:GetDescendants()) do
            if obj:IsA("NumberValue") or obj:IsA("IntValue") then
                local n = obj.Name:lower()
                if n:find("stamina") or n:find("energy") or n:find("endur") or n:find("stam") then
                    if n:find("max") then
                        if not max then max = obj.Value end
                    else
                        if not cur then cur = obj.Value end
                    end
                end
            end
            for attr, val in pairs(obj:GetAttributes()) do
                if type(val) == "number" then
                    local n = attr:lower()
                    if n:find("stamina") or n:find("energy") or n:find("endur") then
                        if n:find("max") then
                            if not max then max = val end
                        else
                            if not cur then cur = val end
                        end
                    end
                end
            end
        end
    end
    if cur then
        if not max or max <= 0 then max = 100 end
        return math.clamp(math.floor((cur/max)*100), 0, 100)
    end

    -- 6. as last resort, gc scan (only for enemies to avoid perf hit)
    if plr ~= player then
        local gcVal = gcScanStamina(plr)
        if gcVal then
            local maxv = 100
            if gcVal > 100 then maxv = gcVal end
            return math.clamp(math.floor((gcVal/maxv)*100), 0, 100)
        end
    end

    return nil
end

-- ============================================
-- WALLPAPER APPLY
-- ============================================
local function applyWallpaper(source)
    if not wallRefs.main then return end
    WALLPAPER_STATE.current = source
    if source == "default" or source == nil then
        wallRefs.main.BackgroundColor3 = THEME.Bg
        if wallRefs.wallImg then
            wallRefs.wallImg.Image = ""
            wallRefs.wallImg.Visible = false
            wallRefs.wallOverlay.Visible = false
        end
        notify("wallpaper: default", "info")
        return
    end
    local url = source
    if WALLPAPERS[source] and WALLPAPERS[source] ~= nil then url = WALLPAPERS[source] end
    if type(url) ~= "string" or url == "" then
        notify("wallpaper preset not configured", "warn")
        return
    end
    if wallRefs.wallImg then
        wallRefs.wallImg.Image = url
        wallRefs.wallImg.Visible = true
        wallRefs.wallOverlay.Visible = true
        wallRefs.main.BackgroundColor3 = Color3.fromRGB(6, 6, 10)
        notify("wallpaper applied", "success")
    end
end

-- ============================================
-- STAMINA (self)
-- ============================================
local staminaRefs = {}
local staminaOriginals = {}
local staminaConns = {}

local function scanForStamina()
    for _, c in ipairs(staminaConns) do if c then c:Disconnect() end end
    table.clear(staminaConns); table.clear(staminaRefs)
    for _, obj in pairs(player:GetDescendants()) do
        if obj:IsA("NumberValue") or obj:IsA("IntValue") then
            local n = obj.Name:lower()
            if n:find("stamina") or n:find("energy") or n:find("endurance") or n:find("sp") then
                table.insert(staminaRefs, obj)
            end
        end
        for attr in pairs(obj:GetAttributes()) do
            local n = attr:lower()
            if n:find("stamina") or n:find("energy") or n:find("endurance") then
                table.insert(staminaRefs, {obj=obj, attr=attr})
            end
        end
    end
    for _, obj in pairs(character:GetDescendants()) do
        if obj:IsA("NumberValue") or obj:IsA("IntValue") then
            local n = obj.Name:lower()
            if n:find("stamina") or n:find("energy") or n:find("endurance") then
                table.insert(staminaRefs, obj)
            end
        end
    end
    return #staminaRefs
end

local function snapshotStamina()
    table.clear(staminaOriginals)
    for i, ref in ipairs(staminaRefs) do
        if type(ref) == "table" then staminaOriginals[i] = ref.obj:GetAttribute(ref.attr)
        else staminaOriginals[i] = ref.Value end
    end
end

local function restoreStamina()
    for i, ref in ipairs(staminaRefs) do
        local original = staminaOriginals[i]
        if type(ref) == "table" then
            pcall(function() if original ~= nil then ref.obj:SetAttribute(ref.attr, original) end end)
        else
            pcall(function() if original ~= nil and ref.Parent then ref.Value = original end end)
        end
    end
    table.clear(staminaOriginals)
end

-- ============================================
-- INFINITE BOOST (Spurt / Ability cooldown removal)
-- ============================================
local boostConns = {}
local boostThread = nil

local function scanBoostValues()
    local refs = {}
    local keywords = {"boost", "spurt", "cooldown", "cd", "ability", "skill", "zone"}
    local function consider(obj, name)
        local n = name:lower()
        for _, kw in ipairs(keywords) do
            if n:find(kw) then
                table.insert(refs, obj)
                return
            end
        end
    end
    for _, obj in pairs(player:GetDescendants()) do
        if obj:IsA("NumberValue") or obj:IsA("IntValue") or obj:IsA("BoolValue") then
            consider(obj, obj.Name)
        end
        for attr, val in pairs(obj:GetAttributes()) do
            if type(val) == "number" or type(val) == "boolean" then
                consider({obj=obj, attr=attr, isAttr=true}, attr)
            end
        end
    end
    if character then
        for _, obj in pairs(character:GetDescendants()) do
            if obj:IsA("NumberValue") or obj:IsA("IntValue") or obj:IsA("BoolValue") then
                consider(obj, obj.Name)
            end
        end
    end
    return refs
end

local function enableInfiniteBoost(state)
    CONFIG.InfiniteBoost = state
    for _, c in ipairs(boostConns) do if c then c:Disconnect() end end
    table.clear(boostConns)
    if boostThread then task.cancel(boostThread); boostThread = nil end
    if not state then
        notify("Infinite Boost off", "info")
        return
    end
    local refs = scanBoostValues()
    notify("Boost: "..#refs.." refs locked", #refs > 0 and "success" or "warn")
    for _, ref in ipairs(refs) do
        if type(ref) == "table" and ref.isAttr then
            pcall(function()
                local cur = ref.obj:GetAttribute(ref.attr)
                if type(cur) == "number" and cur > 0 then
                    ref.obj:SetAttribute(ref.attr, 0)
                elseif type(cur) == "boolean" then
                    ref.obj:SetAttribute(ref.attr, false)
                end
            end)
        elseif typeof(ref) == "Instance" then
            if ref:IsA("BoolValue") then
                pcall(function() ref.Value = false end)
                local conn = ref.Changed:Connect(function()
                    if CONFIG.InfiniteBoost then pcall(function() ref.Value = false end) end
                end)
                table.insert(boostConns, conn)
            else
                pcall(function() if ref.Value and ref.Value > 0 then ref.Value = 0 end end)
                local conn = ref.Changed:Connect(function(v)
                    if CONFIG.InfiniteBoost and type(v) == "number" and v > 0 then
                        pcall(function() ref.Value = 0 end)
                    end
                end)
                table.insert(boostConns, conn)
            end
        end
    end
    -- also spam common keys as fallback (R = Spurt, F = Ability, G = Zone)
    boostThread = task.spawn(function()
        while CONFIG.InfiniteBoost do
            pcall(function()
                VIM:SendKeyEvent(true, Enum.KeyCode.R, false, game)
                VIM:SendKeyEvent(false, Enum.KeyCode.R, false, game)
                VIM:SendKeyEvent(true, Enum.KeyCode.F, false, game)
                VIM:SendKeyEvent(false, Enum.KeyCode.F, false, game)
            end)
            task.wait(0.15)
        end
    end)
end

-- ============================================
-- MODULE STATE
-- ============================================
local speedConn, stamConn, stamThread, qteThread, qteRemote, espConn
local antiAfkConn, antiKickConn, antiStaffConn

-- ============================================
-- KEYBIND SYSTEM
-- ============================================
local KEYBIND_STATE = { listening = nil, listenerConn = nil, uiRefs = nil }

local function keyName(k)
    if typeof(k) == "EnumItem" then return k.Name end
    return tostring(k)
end

local function updateKeybindUI()
    if not KEYBIND_STATE.uiRefs then return end
    local r = KEYBIND_STATE.uiRefs
    if r.staminaBtn then r.staminaBtn.Text = keyName(CONFIG.KeybindStamina) end
    if r.menuBtn then r.menuBtn.Text = keyName(CONFIG.KeybindMenu) end
end

local function startListening(which)
    if KEYBIND_STATE.listenerConn then KEYBIND_STATE.listenerConn:Disconnect(); KEYBIND_STATE.listenerConn = nil end
    KEYBIND_STATE.listening = which
    if KEYBIND_STATE.uiRefs then
        local btn = which == "stamina" and KEYBIND_STATE.uiRefs.staminaBtn or KEYBIND_STATE.uiRefs.menuBtn
        if btn then btn.Text = "press a key..."; btn.TextColor3 = THEME.Yellow end
    end
    KEYBIND_STATE.listenerConn = UserInputService.InputBegan:Connect(function(input, gpe)
        if gpe then return end
        if input.UserInputType ~= Enum.UserInputType.Keyboard then return end
        if input.KeyCode == Enum.KeyCode.Unknown then return end
        if which == "stamina" then CONFIG.KeybindStamina = input.KeyCode
        elseif which == "menu" then CONFIG.KeybindMenu = input.KeyCode end
        if KEYBIND_STATE.listenerConn then KEYBIND_STATE.listenerConn:Disconnect(); KEYBIND_STATE.listenerConn = nil end
        KEYBIND_STATE.listening = nil
        if KEYBIND_STATE.uiRefs then
            local b2 = which == "stamina" and KEYBIND_STATE.uiRefs.staminaBtn or KEYBIND_STATE.uiRefs.menuBtn
            if b2 then b2.TextColor3 = THEME.Text end
        end
        updateKeybindUI()
        notify("Bound "..which.." → "..input.KeyCode.Name, "success")
    end)
end

-- ============================================
-- SPEED / STAMINA
-- ============================================
local function applySpeed()
    if humanoid and humanoid.Parent then
        local s = 16 * CONFIG.SpeedMultiplier
        local j = 50 * CONFIG.SpeedMultiplier
        if humanoid.WalkSpeed ~= s then humanoid.WalkSpeed = s end
        if humanoid.JumpPower ~= j then humanoid.JumpPower = j end
    end
end

local function enableSpeedBoost(state)
    CONFIG.SpeedBoost = state
    if state then
        if speedConn then speedConn:Disconnect() end
        speedConn = RunService.RenderStepped:Connect(applySpeed)
        notify("Speed Boost enabled", "success")
    else
        if speedConn then speedConn:Disconnect(); speedConn=nil end
        if humanoid then humanoid.WalkSpeed=16; humanoid.JumpPower=50 end
        notify("Speed Boost disabled", "info")
    end
end

local function enableInfiniteStamina(state)
    CONFIG.InfiniteStamina = state
    if state then
        for _, c in ipairs(staminaConns) do if c then c:Disconnect() end end
        table.clear(staminaConns)
        local n = scanForStamina()
        snapshotStamina()
        notify("Stamina: "..n.." refs locked", n>0 and "success" or "warn")
        for i, ref in ipairs(staminaRefs) do
            if type(ref) ~= "table" then
                local lastGood = ref.Value or 100
                local conn = ref.Changed:Connect(function(newVal)
                    if not CONFIG.InfiniteStamina then return end
                    if newVal < lastGood then
                        pcall(function() ref.Value = lastGood end)
                    else lastGood = newVal end
                end)
                table.insert(staminaConns, conn)
            end
        end
        stamThread = task.spawn(function()
            while CONFIG.InfiniteStamina and task.wait(0.15) do
                pcall(function()
                    for _, ref in pairs(staminaRefs) do
                        if type(ref) == "table" then
                            local cur = ref.obj:GetAttribute(ref.attr)
                            if type(cur) == "number" and cur < 90 then
                                ref.obj:SetAttribute(ref.attr, 100)
                            end
                        else
                            if ref.Parent and type(ref.Value) == "number" and ref.Value < 90 then
                                ref.Value = 100
                            end
                        end
                    end
                    -- also try humanoid attributes common in Uma Racing
                    if character then
                        for _, attr in ipairs({"Stamina", "stamina", "Energy", "energy", "SP", "sp"}) do
                            local v = character:GetAttribute(attr)
                            if type(v) == "number" and v < 90 then
                                character:SetAttribute(attr, 100)
                            end
                        end
                        if player then
                            for _, attr in ipairs({"Stamina", "stamina", "Energy", "energy"}) do
                                local v = player:GetAttribute(attr)
                                if type(v) == "number" and v < 90 then
                                    player:SetAttribute(attr, 100)
                                end
                            end
                        end
                    end
                end)
            end
        end)
    else
        for _, c in ipairs(staminaConns) do if c then c:Disconnect() end end
        table.clear(staminaConns)
        if stamThread then task.cancel(stamThread); stamThread = nil end
        if stamConn then stamConn:Disconnect(); stamConn = nil end
        task.wait(0.1)
        restoreStamina()
        notify("Infinite Stamina off", "info")
    end
end

-- ============================================
-- ANTI-AFK
-- ============================================
local function enableAntiAFK(state)
    CONFIG.AntiAFK = state
    if state then
        antiAfkConn = player.Idled:Connect(function()
            pcall(function()
                VirtualUser:CaptureController()
                VirtualUser:ClickButton2(Vector2.new())
            end)
        end)
        task.spawn(function()
            while CONFIG.AntiAFK do
                task.wait(45)
                if CONFIG.AntiAFK and humanoid and humanoid.Parent then
                    pcall(function()
                        VirtualUser:CaptureController()
                        VirtualUser:ClickButton2(Vector2.new())
                    end)
                end
            end
        end)
        notify("Anti-AFK enabled", "success")
    else
        if antiAfkConn then antiAfkConn:Disconnect(); antiAfkConn = nil end
        notify("Anti-AFK off", "info")
    end
end

-- ============================================
-- ANTI-KICK
-- ============================================
local function enableAntiKick(state)
    CONFIG.AntiKick = state
    if state then
        if getrawmetatable then
            local mt = getrawmetatable(game)
            if mt and not mt.__RAKAHOOKED then
                local oldNamecall = mt.__namecall
                setreadonly(mt, false)
                mt.__namecall = newcclosure(function(self, ...)
                    local method = getnamecallmethod()
                    if method == "Kick" and CONFIG.AntiKick then
                        notify("Kick attempt blocked", "warn")
                        return
                    end
                    return oldNamecall(self, ...)
                end)
                setreadonly(mt, true)
                mt.__RAKAHOOKED = true
            end
        end
        for _, obj in pairs(ReplicatedStorage:GetDescendants()) do
            if obj:IsA("RemoteEvent") then
                local n = obj.Name:lower()
                if n:find("kick") or n:find("ban") or n:find("remove") then
                    pcall(function()
                        obj.OnClientEvent:Connect(function()
                            if CONFIG.AntiKick then notify("Kick remote blocked: "..obj.Name, "warn") end
                        end)
                    end)
                end
            end
        end
        notify("Anti-Kick enabled", "success")
    else
        notify("Anti-Kick off", "info")
    end
end

-- ============================================
-- ANTI-STAFF
-- ============================================
local STAFF_KEYWORDS = {
    "admin", "staff", "mod", "moderator", "owner", "dev", "developer",
    "rakausume", "raka", "creator", "founder", "manager", "supervisor",
    "booger", "rayban", "rakakick"
}

local function isStaff(plr)
    local name = plr.Name:lower()
    local display = plr.DisplayName:lower()
    for _, kw in ipairs(STAFF_KEYWORDS) do
        if name:find(kw) or display:find(kw) then return true, kw end
    end
    for _, obj in pairs(plr:GetChildren()) do
        if obj:IsA("StringValue") then
            local v = tostring(obj.Value):lower()
            for _, kw in ipairs(STAFF_KEYWORDS) do
                if v:find(kw) then return true, kw end
            end
        end
    end
    return false
end

local function enableAntiStaff(state)
    CONFIG.AntiStaff = state
    if state then
        antiStaffConn = Players.PlayerAdded:Connect(function(plr)
            if not CONFIG.AntiStaff then return end
            task.wait(0.5)
            local staff, kw = isStaff(plr)
            if staff then
                notify("STAFF DETECTED: "..plr.Name.." ("..kw..")", "error", 6)
                if CONFIG.PlayerESP then enablePlayerESP(false); if espToggleCardRef then espToggleCardRef(false) end end
                if CONFIG.SpeedBoost then enableSpeedBoost(false); if speedToggleCardRef then speedToggleCardRef(false) end end
                if CONFIG.AutoQTE then enableAutoQTE(false); if qteToggleCardRef then qteToggleCardRef(false) end end
                if CONFIG.InfiniteStamina then enableInfiniteStamina(false); if staminaToggleCardRef then staminaToggleCardRef(false) end end
            end
        end)
        for _, plr in ipairs(Players:GetPlayers()) do
            if plr ~= player then
                local staff, kw = isStaff(plr)
                if staff then notify("STAFF in server: "..plr.Name, "error", 6) end
            end
        end
        notify("Anti-Staff enabled", "success")
    else
        if antiStaffConn then antiStaffConn:Disconnect(); antiStaffConn = nil end
        notify("Anti-Staff off", "info")
    end
end

-- ============================================
-- QTE
-- ============================================
local function dumpRemotes()
    print("=== RAKAUSUME REMOTE DUMP ===")
    for _, cont in ipairs({ReplicatedStorage, ReplicatedFirst, player, character}) do
        for _, obj in pairs(cont:GetDescendants()) do
            if obj:IsA("RemoteEvent") or obj:IsA("RemoteFunction")
               or obj:IsA("BindableEvent") or obj:IsA("BindableFunction") then
                print("  ["..obj.ClassName.."] "..obj:GetFullName())
            end
        end
    end
    print("=== END DUMP ===")
end

local function findQTE()
    local containers = {ReplicatedStorage, ReplicatedFirst, player, character}
    local keywords = {"qte","quick","input","action","press","tap","hit","perfect","timing",
        "race","sprint","boost","dash","jump","click","button","keystroke","key","prompt"}
    for _, container in ipairs(containers) do
        for _, obj in pairs(container:GetDescendants()) do
            if obj:IsA("RemoteEvent") or obj:IsA("RemoteFunction")
               or obj:IsA("BindableEvent") or obj:IsA("BindableFunction") then
                local n = obj.Name:lower()
                for _, kw in ipairs(keywords) do if n:find(kw) then return obj end end
            end
        end
    end
    return nil
end

local function findActivePrompt()
    for _, obj in pairs(workspace:GetDescendants()) do
        if obj:IsA("ProximityPrompt") and obj.Enabled then return obj end
    end
    return nil
end

local function firePrompt(prompt)
    if prompt and prompt:IsA("ProximityPrompt") then
        pcall(function()
            if fireproximityprompt then fireproximityprompt(prompt)
            else prompt:InputHoldBegin(); task.wait(0.05); prompt:InputHoldEnd() end
        end)
    end
end

local function pressKey(key)
    local code = typeof(key) == "EnumItem" and key or Enum.KeyCode[key]
    if code then
        pcall(function()
            VIM:SendKeyEvent(true, code, false, game)
            VIM:SendKeyEvent(false, code, false, game)
        end)
    end
end

local function clickCenter()
    pcall(function()
        local cam = workspace.CurrentCamera
        if not cam then return end
        local pos = cam.ViewportSize / 2
        VIM:SendMouseButtonEvent(pos.X, pos.Y, 0, true, game, 0)
        VIM:SendMouseButtonEvent(pos.X, pos.Y, 0, false, game, 0)
    end)
end

local function fireQTE()
    if qteRemote then
        pcall(function()
            if qteRemote:IsA("RemoteEvent") then qteRemote:FireServer()
            elseif qteRemote:IsA("RemoteFunction") then qteRemote:InvokeServer()
            elseif qteRemote:IsA("BindableEvent") then qteRemote:Fire()
            elseif qteRemote:IsA("BindableFunction") then qteRemote:Invoke() end
        end)
    end
    if CONFIG.QTEUsePromptClick then
        local p = findActivePrompt()
        if p then firePrompt(p) end
    end
    pressKey("Space"); pressKey("E"); pressKey("F"); pressKey("Q")
    clickCenter()
end

local function stopQTE()
    if qteThread then task.cancel(qteThread); qteThread = nil end
    qteRemote = nil
end

local function startQTE()
    stopQTE()
    dumpRemotes()
    qteRemote = findQTE()
    if qteRemote then
        notify("QTE hooked: "..qteRemote.Name, "success")
    else notify("QTE: input spam mode", "warn") end
    qteThread = task.spawn(function()
        while CONFIG.AutoQTE do
            local rate = math.clamp(CONFIG.QTERate or 0.01, 0.005, 0.5)
            fireQTE()
            task.wait(rate)
        end
    end)
end

local function enableAutoQTE(state)
    CONFIG.AutoQTE = state
    if state then startQTE()
    else stopQTE(); notify("Auto QTE off", "info") end
end

-- ============================================
-- PLAYER ESP
-- ============================================
local espFolder = nil
local espEntries = {}
local espRGBThread = nil
local charCache = {}

local function detectCharacterFast(str)
    if not str or str == "" then return nil end
    local lower = str:lower()
    if lower == HARDEST_CHAR or lower:find(HARDEST_CHAR, 1, true) then return CHARACTERS[HARDEST_CHAR] end
    for key, display in pairs(CHARACTERS) do
        if key ~= HARDEST_CHAR then
            if lower == key or lower:find(key, 1, true) then return display end
        end
    end
    return nil
end

local function scanCharacterName(plr)
    local char = plr.Character
    if not char then return nil, false end
    local matches = {}
    local function tryMatch(s)
        if not s or s == "" then return end
        local lower = s:lower()
        for key, display in pairs(CHARACTERS) do
            if lower == key or lower:find(key, 1, true) then
                table.insert(matches, {key = key, display = display, len = #key})
            end
        end
    end
    for _, val in pairs(plr:GetAttributes()) do if type(val) == "string" then tryMatch(val) end end
    for _, obj in pairs(plr:GetChildren()) do if obj:IsA("StringValue") then tryMatch(obj.Value) end end
    for _, child in pairs(char:GetChildren()) do
        tryMatch(child.Name)
        if child:IsA("StringValue") then tryMatch(child.Value) end
        if child:IsA("Model") and not child:FindFirstChildOfClass("Humanoid") then tryMatch(child.Name) end
        for _, val in pairs(child:GetAttributes()) do if type(val) == "string" then tryMatch(val) end end
    end
    if #matches == 0 then return nil, false end
    table.sort(matches, function(a, b) return a.len > b.len end)
    local best = matches[1]
    return best.display, best.key == HARDEST_CHAR
end

local function createESP(plr)
    if plr == player then return end
    if espEntries[plr] then return end
    local char = plr.Character
    if not char then return end

    local highlight = Instance.new("Highlight")
    highlight.Name = "RAKAUSUME_ESP"
    highlight.Adornee = char
    highlight.FillColor = THEME.Red
    highlight.FillTransparency = 0.6
    highlight.OutlineColor = THEME.Red
    highlight.OutlineTransparency = 0
    highlight.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop
    highlight.Parent = espFolder

    local billboard = Instance.new("BillboardGui")
    billboard.Name = "RAKAUSUME_ESP_LABEL"
    billboard.Size = UDim2.new(0, 250, 0, 70)
    billboard.StudsOffset = Vector3.new(0, 3.2, 0)
    billboard.AlwaysOnTop = true
    billboard.Adornee = char:FindFirstChild("Head") or char:FindFirstChildOfClass("BasePart") or char.PrimaryPart
    billboard.Parent = espFolder

    local container = Instance.new("Frame")
    container.Size = UDim2.new(1, 0, 1, 0)
    container.BackgroundColor3 = THEME.Bg
    container.BackgroundTransparency = 0.1
    container.BorderSizePixel = 0
    container.Parent = billboard
    corner(container, 8)
    local containerStroke = stroke(container, THEME.Red, 1.4, 0.15)

    local nameLbl = Instance.new("TextLabel")
    nameLbl.Size = UDim2.new(1, -10, 0, 16)
    nameLbl.Position = UDim2.new(0, 5, 0, 5)
    nameLbl.BackgroundTransparency = 1
    nameLbl.Text = plr.DisplayName
    nameLbl.TextColor3 = THEME.Text
    nameLbl.TextSize = 12
    nameLbl.Font = Enum.Font.GothamBold
    nameLbl.TextXAlignment = Enum.TextXAlignment.Left
    nameLbl.TextTruncate = Enum.TextTruncate.AtEnd
    nameLbl.Parent = container

    local charLbl = Instance.new("TextLabel")
    charLbl.Size = UDim2.new(1, -10, 0, 14)
    charLbl.Position = UDim2.new(0, 5, 0, 22)
    charLbl.BackgroundTransparency = 1
    charLbl.Text = "char: scanning..."
    charLbl.TextColor3 = CONFIG.AccentColor
    charLbl.TextSize = 11
    charLbl.Font = Enum.Font.GothamBold
    charLbl.TextXAlignment = Enum.TextXAlignment.Left
    charLbl.TextTruncate = Enum.TextTruncate.AtEnd
    charLbl.Parent = container

    local hardLbl = Instance.new("TextLabel")
    hardLbl.Size = UDim2.new(0, 80, 0, 14)
    hardLbl.Position = UDim2.new(1, -85, 0, 38)
    hardLbl.BackgroundTransparency = 1
    hardLbl.Text = "HARDEST"
    hardLbl.TextColor3 = THEME.Orange
    hardLbl.TextSize = 10
    hardLbl.Font = Enum.Font.GothamBold
    hardLbl.TextXAlignment = Enum.TextXAlignment.Right
    hardLbl.Visible = false
    hardLbl.Parent = container

    local stamLbl = Instance.new("TextLabel")
    stamLbl.Size = UDim2.new(1, -10, 0, 14)
    stamLbl.Position = UDim2.new(0, 5, 0, 52)
    stamLbl.BackgroundTransparency = 1
    stamLbl.Text = "stamina: --%"
    stamLbl.TextColor3 = THEME.Green
    stamLbl.TextSize = 10
    stamLbl.Font = Enum.Font.GothamBold
    stamLbl.TextXAlignment = Enum.TextXAlignment.Left
    stamLbl.Parent = container

    espEntries[plr] = {
        highlight = highlight,
        billboard = billboard,
        containerStroke = containerStroke,
        nameLbl = nameLbl,
        charLbl = charLbl,
        hardLbl = hardLbl,
        stamLbl = stamLbl,
        lastCharName = nil,
        lastStamText = nil,
        lastStamScan = 0,
    }
end

local function removeESP(plr)
    local e = espEntries[plr]
    if not e then return end
    if e.highlight then e.highlight:Destroy() end
    if e.billboard then e.billboard:Destroy() end
    espEntries[plr] = nil
    charCache[plr] = nil
end

local function refreshESP()
    for plr, e in pairs(espEntries) do
        local char = plr.Character
        if not char or not char.Parent then
            removeESP(plr)
        else
            local head = char:FindFirstChild("Head") or char.PrimaryPart
            if head and e.billboard.Adornee ~= head then e.billboard.Adornee = head end
            if e.highlight.Adornee ~= char then e.highlight.Adornee = char end
            local now = tick()
            local cache = charCache[plr]
            if not cache or now - cache.lastScan > 2 then
                local cname, isHardest = scanCharacterName(plr)
                if not cname then cname = "Unknown" end
                charCache[plr] = { name = cname, hardest = isHardest, lastScan = now }
                cache = charCache[plr]
            end
            if cache.name ~= e.lastCharName then
                e.lastCharName = cache.name
                e.charLbl.Text = "char: "..cache.name
                if cache.hardest then
                    e.charLbl.TextColor3 = THEME.Orange
                    e.hardLbl.Visible = true
                else
                    e.charLbl.TextColor3 = CONFIG.AccentColor
                    e.hardLbl.Visible = false
                end
            end
            if now - e.lastStamScan > 0.25 then
                e.lastStamScan = now
                local pct = getPlayerStaminaPercent(plr)
                local newText, newColor
                if pct then
                    newText = "stamina: "..pct.."%"
                    if pct > 60 then newColor = THEME.Green
                    elseif pct > 30 then newColor = THEME.Yellow
                    else newColor = THEME.Red end
                else
                    newText = "stamina: n/a"
                    newColor = THEME.TextDim
                end
                if newText ~= e.lastStamText then
                    e.lastStamText = newText
                    e.stamLbl.Text = newText
                    e.stamLbl.TextColor3 = newColor
                end
            end
        end
    end
end

local function startESPRGB()
    if espRGBThread then return end
    espRGBThread = task.spawn(function()
        local t = 0
        while CONFIG.PlayerESP and CONFIG.ESPRGBBorder do
            t = (t + 0.015) % 1
            local color = Color3.fromHSV(t, 1, 1)
            for _, e in pairs(espEntries) do
                if e.highlight then
                    e.highlight.OutlineColor = color
                    e.highlight.FillColor = color
                end
                if e.containerStroke then e.containerStroke.Color = color end
            end
            task.wait(0.05)
        end
        espRGBThread = nil
    end)
end

local function stopESPRGB()
    if espRGBThread then task.cancel(espRGBThread); espRGBThread = nil end
    for _, e in pairs(espEntries) do
        if e.highlight then
            e.highlight.OutlineColor = THEME.Red
            e.highlight.FillColor = THEME.Red
        end
        if e.containerStroke then e.containerStroke.Color = THEME.Red end
    end
end

local playerAddedConn, playerRemovingConn

local function startESP()
    if espFolder then espFolder:Destroy() end
    espFolder = Instance.new("Folder")
    espFolder.Name = "RAKAUSUME_ESP_FOLDER"
    espFolder.Parent = CoreGui
    for _, plr in ipairs(Players:GetPlayers()) do
        if plr ~= player then createESP(plr) end
    end
    playerAddedConn = Players.PlayerAdded:Connect(function(plr)
        if CONFIG.PlayerESP and plr ~= player then
            plr.CharacterAdded:Connect(function()
                task.wait(0.5)
                if CONFIG.PlayerESP then createESP(plr) end
            end)
            if plr.Character then createESP(plr) end
        end
    end)
    playerRemovingConn = Players.PlayerRemoving:Connect(function(plr)
        removeESP(plr)
        staminaCache[plr] = nil
    end)
    task.spawn(function()
        while CONFIG.PlayerESP and espFolder do
            for _, plr in ipairs(Players:GetPlayers()) do
                if plr ~= player and not espEntries[plr] and plr.Character then createESP(plr) end
            end
            refreshESP()
            task.wait(0.05)
        end
    end)
    if CONFIG.ESPRGBBorder then startESPRGB() end
    notify("Player ESP enabled", "success")
end

local function stopESP()
    if playerAddedConn then playerAddedConn:Disconnect(); playerAddedConn = nil end
    if playerRemovingConn then playerRemovingConn:Disconnect(); playerRemovingConn = nil end
    stopESPRGB()
    for plr, _ in pairs(espEntries) do removeESP(plr) end
    if espFolder then espFolder:Destroy(); espFolder = nil end
    notify("Player ESP off", "info")
end

local function enablePlayerESP(state)
    CONFIG.PlayerESP = state
    if state then startESP() else stopESP() end
end

local function enableESPRGB(state)
    CONFIG.ESPRGBBorder = state
    if state and CONFIG.PlayerESP then startESPRGB(); notify("RGB border on", "success")
    else stopESPRGB(); notify("RGB border off", "info") end
end

-- ============================================
-- CODE SYSTEM
-- ============================================
local CODE_STATE = { active = {} }
local navBtnsRef, pagesRef

local CODES = {
    ["FightClub"] = function(active)
        if active then
            CODE_STATE.fightClubThread = task.spawn(function()
                local lines = {
                    "you do not talk about fight club",
                    "do you know why you wonder on your own life?",
                    "like the space monkey, after we lost everything that why we feel free",
                    "forget it man if you have something to say then say it!",
                    "fuck all of those people",
                    "stop controlling everything and just LET GO!",
                    "do you even exist?",
                    "stop this tyler, no you DONT!",
                }
                while CODE_STATE.active["FightClub"] do
                    for _, line in ipairs(lines) do print(line) end
                    task.wait(0.05)
                end
            end)
        else
            if CODE_STATE.fightClubThread then
                task.cancel(CODE_STATE.fightClubThread)
                CODE_STATE.fightClubThread = nil
            end
        end
    end,

    ["Rainbow"] = function(active)
        if active then
            CODE_STATE.rainbowThread = task.spawn(function()
                local t = 0
                while CODE_STATE.active["Rainbow"] do
                    t = (t + 0.02) % 1
                    local color = Color3.fromHSV(t, 1, 1)
                    for _, e in pairs(espEntries) do
                        if e.highlight then
                            e.highlight.OutlineColor = color
                            e.highlight.FillColor = color
                        end
                        if e.containerStroke then e.containerStroke.Color = color end
                    end
                    task.wait(0.03)
                end
            end)
        else
            if CODE_STATE.rainbowThread then
                task.cancel(CODE_STATE.rainbowThread)
                CODE_STATE.rainbowThread = nil
            end
        end
    end,

    ["Speed"] = function(active)
        if active then
            CONFIG.SpeedMultiplier = 5
            if CONFIG.SpeedBoost then applySpeed() end
            notify("speed multiplier set to 5x", "success")
        else
            CONFIG.SpeedMultiplier = 2.5
            notify("speed multiplier reset to 2.5x", "info")
        end
    end,

    ["6767"] = function(active)
        if active then
            notify("6767 6767 6767 6767", "success", 5)
            for i = 1, 67 do print("6767 — gng") end
        end
    end,

    ["DeepScan"] = function(active)
        if active then
            CONFIG.DeepStamScan = true
            notify("deep stamina scan enabled", "success")
        else
            CONFIG.DeepStamScan = false
            notify("deep stamina scan off", "info")
        end
    end,
}

local function runCode(code)
    if code == "iloveoguri1023" then
        if not WALLPAPER_STATE.unlocked then
            WALLPAPER_STATE.unlocked = true
            notify("welcome, dev or raka, would you want to change the wallpaper of the ui?", "success", 7)
            if navBtnsRef and navBtnsRef["Wallpaper"] then
                navBtnsRef["Wallpaper"].btn.Visible = true
                task.spawn(function()
                    for i = 1, 4 do
                        tween(navBtnsRef["Wallpaper"].btn, 0.25, {BackgroundColor3 = CONFIG.AccentColor})
                        task.wait(0.25)
                        tween(navBtnsRef["Wallpaper"].btn, 0.25, {BackgroundColor3 = THEME.Bg2})
                        task.wait(0.25)
                    end
                end)
            end
        else
            notify("wallpaper already unlocked", "info")
        end
        return true
    end
    if CODES[code] then
        CODE_STATE.active[code] = not CODE_STATE.active[code]
        CODES[code](CODE_STATE.active[code])
        return CODE_STATE.active[code]
    end
    return nil
end

-- ============================================
-- BOOT SPLASH
-- ============================================
local function bootSplash()
    local splash = Instance.new("Frame")
    splash.Size = UDim2.new(0, 460, 0, 240)
    splash.Position = UDim2.new(0.5, -230, 0.5, -120)
    splash.BackgroundColor3 = THEME.Bg
    splash.BorderSizePixel = 0
    splash.ZIndex = 100
    splash.Parent = CoreGui
    corner(splash, 24)
    local spStroke = stroke(splash, CONFIG.AccentColor, 1.6, 0.3)
    grad(splash, THEME.Bg, Color3.fromRGB(18, 12, 30), 60)

    task.spawn(function()
        local t = 0
        while splash.Parent do
            t += 0.03
            local p = (math.sin(t) + 1) / 2
            spStroke.Transparency = 0.3 + (p * 0.4)
            spStroke.Color = CONFIG.AccentColor:Lerp(CONFIG.AccentAlt, p)
            task.wait(0.03)
        end
    end)

    -- double-ring logo
    local ring2 = Instance.new("Frame")
    ring2.Size = UDim2.new(0, 96, 0, 96)
    ring2.Position = UDim2.new(0.5, -48, 0, 26)
    ring2.BackgroundTransparency = 1
    ring2.ZIndex = 101
    ring2.Parent = splash
    local ring2Stroke = Instance.new("UIStroke")
    ring2Stroke.Color = CONFIG.AccentAlt
    ring2Stroke.Thickness = 1
    ring2Stroke.Transparency = 0.6
    ring2Stroke.Parent = ring2
    corner(ring2, 48)

    local circle = Instance.new("Frame")
    circle.Size = UDim2.new(0, 74, 0, 74)
    circle.Position = UDim2.new(0.5, -37, 0, 37)
    circle.BackgroundColor3 = CONFIG.AccentColor
    circle.BorderSizePixel = 0
    circle.ZIndex = 102
    circle.Parent = splash
    corner(circle, 37)
    grad(circle, CONFIG.AccentColor, CONFIG.AccentAlt, 45)

    local circleR = Instance.new("TextLabel")
    circleR.Size = UDim2.new(1, 0, 1, 0)
    circleR.BackgroundTransparency = 1
    circleR.Text = "R"
    circleR.TextColor3 = Color3.fromRGB(255,255,255)
    circleR.TextSize = 36
    circleR.Font = Enum.Font.GothamBold
    circleR.ZIndex = 103
    circleR.Parent = circle

    local ring = Instance.new("Frame")
    ring.Size = UDim2.new(0, 84, 0, 84)
    ring.Position = UDim2.new(0.5, -42, 0, 32)
    ring.BackgroundTransparency = 1
    ring.ZIndex = 101
    ring.Parent = splash
    local ringStroke = Instance.new("UIStroke")
    ringStroke.Color = CONFIG.AccentColor
    ringStroke.Thickness = 2
    ringStroke.Transparency = 0.3
    ringStroke.Parent = ring
    corner(ring, 42)

    task.spawn(function()
        while ring.Parent do
            local rot = tick() * 180
            ringStroke.Transparency = 0.2 + (math.sin(rot/30) + 1)/2 * 0.4
            task.wait(0.03)
        end
    end)

    local logo = Instance.new("TextLabel")
    logo.Size = UDim2.new(1, 0, 0, 32)
    logo.Position = UDim2.new(0, 0, 0, 126)
    logo.BackgroundTransparency = 1
    logo.Text = "RAKAUSUME"
    logo.TextColor3 = THEME.Text
    logo.TextSize = 28
    logo.Font = Enum.Font.GothamBold
    logo.ZIndex = 102
    logo.Parent = splash

    local ver = Instance.new("TextLabel")
    ver.Size = UDim2.new(1, 0, 0, 16)
    ver.Position = UDim2.new(0, 0, 0, 158)
    ver.BackgroundTransparency = 1
    ver.Text = "UmaRacing Exploit Kit v18"
    ver.TextColor3 = THEME.TextDim
    ver.TextSize = 11
    ver.Font = Enum.Font.Gotham
    ver.ZIndex = 102
    ver.Parent = splash

    local barBg = Instance.new("Frame")
    barBg.Size = UDim2.new(0.7, 0, 0, 5)
    barBg.Position = UDim2.new(0.15, 0, 1, -44)
    barBg.BackgroundColor3 = THEME.Bg4
    barBg.BorderSizePixel = 0
    barBg.ZIndex = 102
    barBg.Parent = splash
    corner(barBg, 3)

    local bar = Instance.new("Frame")
    bar.Size = UDim2.new(0, 0, 1, 0)
    bar.BackgroundColor3 = CONFIG.AccentColor
    bar.BorderSizePixel = 0
    bar.ZIndex = 103
    bar.Parent = barBg
    corner(bar, 3)
    grad(bar, CONFIG.AccentColor, CONFIG.AccentAlt)

    local loading = Instance.new("TextLabel")
    loading.Size = UDim2.new(1, 0, 0, 14)
    loading.Position = UDim2.new(0, 0, 1, -24)
    loading.BackgroundTransparency = 1
    loading.Text = "loading..."
    loading.TextColor3 = THEME.TextDim2
    loading.TextSize = 10
    loading.Font = Enum.Font.Gotham
    loading.ZIndex = 102
    loading.Parent = splash

    local phrases = {"loading core...", "injecting ui...", "hooking modules...", "ready."}
    task.spawn(function()
        for i, p in ipairs(phrases) do
            loading.Text = p
            task.wait(0.4)
        end
    end)

    tween(bar, 1.6, {Size = UDim2.new(1, 0, 1, 0)})
    task.wait(1.8)

    tween(splash, 0.4, {BackgroundTransparency=1})
    for _, c in pairs(splash:GetDescendants()) do
        if c:IsA("TextLabel") then tween(c, 0.35, {TextTransparency=1}) end
        if c:IsA("Frame") then tween(c, 0.35, {BackgroundTransparency=1}) end
        if c:IsA("UIStroke") then tween(c, 0.35, {Transparency=1}) end
    end
    task.wait(0.5)
    splash:Destroy()
end

-- ============================================
-- MAIN UI
-- ============================================
local function buildUI()
    if CoreGui:FindFirstChild("RAKAUSUME") then CoreGui.RAKAUSUME:Destroy() end

    local gui = Instance.new("ScreenGui")
    gui.Name = "RAKAUSUME"
    gui.ResetOnSpawn = false
    gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
    gui.Parent = CoreGui

    notifHolder = Instance.new("Frame")
    notifHolder.Size = UDim2.new(0, 320, 1, 0)
    notifHolder.Position = UDim2.new(1, -320, 0, 20)
    notifHolder.BackgroundTransparency = 1
    notifHolder.ZIndex = 50
    notifHolder.Parent = gui

    local main = Instance.new("Frame")
    main.Size = UDim2.new(0, 700, 0, 480)
    main.Position = UDim2.new(0.5, -350, 0.5, -240)
    main.BackgroundColor3 = THEME.Bg
    main.BorderSizePixel = 0
    main.Active = true
    main.ClipsDescendants = true
    main.Parent = gui
    corner(main, 20)
    local mainStroke = stroke(main, CONFIG.AccentColor, 1.6, 0.35)

    -- animated bg gradient (multi-stage)
    local bgGrad = grad(main, THEME.Bg, Color3.fromRGB(14, 10, 26), 60)

    -- wallpaper layer
    local wallImg = Instance.new("ImageLabel")
    wallImg.Name = "Wallpaper"
    wallImg.Size = UDim2.new(1, 0, 1, 0)
    wallImg.BackgroundTransparency = 1
    wallImg.Image = ""
    wallImg.Visible = false
    wallImg.ZIndex = 0
    wallImg.ScaleType = Enum.ScaleType.Crop
    wallImg.Parent = main
    corner(wallImg, 20)

    local wallOverlay = Instance.new("Frame")
    wallOverlay.Name = "WallpaperOverlay"
    wallOverlay.Size = UDim2.new(1, 0, 1, 0)
    wallOverlay.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
    wallOverlay.BackgroundTransparency = 0.4
    wallOverlay.BorderSizePixel = 0
    wallOverlay.ZIndex = 1
    wallOverlay.Visible = false
    wallOverlay.Parent = main
    corner(wallOverlay, 20)

    -- ambient glow orbs (background)
    local glow1 = Instance.new("Frame")
    glow1.Size = UDim2.new(0, 200, 0, 200)
    glow1.Position = UDim2.new(0, -60, 0, -60)
    glow1.BackgroundColor3 = CONFIG.AccentColor
    glow1.BackgroundTransparency = 0.92
    glow1.BorderSizePixel = 0
    glow1.ZIndex = 1
    glow1.Parent = main
    corner(glow1, 100)

    local glow2 = Instance.new("Frame")
    glow2.Size = UDim2.new(0, 180, 0, 180)
    glow2.Position = UDim2.new(1, -120, 1, -120)
    glow2.BackgroundColor3 = CONFIG.AccentAlt
    glow2.BackgroundTransparency = 0.94
    glow2.BorderSizePixel = 0
    glow2.ZIndex = 1
    glow2.Parent = main
    corner(glow2, 90)

    wallRefs.main = main
    wallRefs.wallImg = wallImg
    wallRefs.wallOverlay = wallOverlay
    wallRefs.bgGrad = bgGrad
    wallRefs.glow1 = glow1
    wallRefs.glow2 = glow2

    -- pulsing border
    task.spawn(function()
        local t = 0
        while main.Parent do
            t += 0.02
            local p = (math.sin(t) + 1) / 2
            mainStroke.Transparency = 0.3 + (p * 0.3)
            mainStroke.Color = CONFIG.AccentColor:Lerp(CONFIG.AccentAlt, p)
            glow1.BackgroundTransparency = 0.9 + (p * 0.05)
            glow2.BackgroundTransparency = 0.92 + (p * 0.04)
            task.wait(0.03)
        end
    end)

    main.Size = UDim2.new(0, 700, 0, 0)
    tween(main, 0.5, {Size = UDim2.new(0, 700, 0, 480)})

    -- SIDEBAR
    local sidebar = Instance.new("Frame")
    sidebar.Size = UDim2.new(0, 190, 1, 0)
    sidebar.BackgroundColor3 = THEME.Bg2
    sidebar.BackgroundTransparency = 0.15
    sidebar.BorderSizePixel = 0
    sidebar.ZIndex = 5
    sidebar.Parent = main
    corner(sidebar, 20)
    local sideFix = Instance.new("Frame")
    sideFix.Size = UDim2.new(0, 18, 1, 0)
    sideFix.Position = UDim2.new(1, -18, 0, 0)
    sideFix.BackgroundColor3 = THEME.Bg2
    sideFix.BackgroundTransparency = 0.15
    sideFix.BorderSizePixel = 0
    sideFix.ZIndex = 5
    sideFix.Parent = sidebar

    -- logo panel
    local logoBox = Instance.new("Frame")
    logoBox.Size = UDim2.new(1, 0, 0, 96)
    logoBox.BackgroundColor3 = THEME.Bg3
    logoBox.BackgroundTransparency = 0.1
    logoBox.BorderSizePixel = 0
    logoBox.ZIndex = 6
    logoBox.Parent = sidebar
    corner(logoBox, 20)
    local logoFix = Instance.new("Frame")
    logoFix.Size = UDim2.new(1, 0, 0, 18)
    logoFix.Position = UDim2.new(0, 0, 1, -18)
    logoFix.BackgroundColor3 = THEME.Bg3
    logoFix.BackgroundTransparency = 0.1
    logoFix.BorderSizePixel = 0
    logoFix.ZIndex = 6
    logoFix.Parent = logoBox
    local logoGrad = grad(logoBox, Color3.fromRGB(22, 16, 40), THEME.Bg3, 0)

    local logoDot = Instance.new("Frame")
    logoDot.Size = UDim2.new(0, 48, 0, 48)
    logoDot.Position = UDim2.new(0, 18, 0, 24)
    logoDot.BackgroundColor3 = CONFIG.AccentColor
    logoDot.BorderSizePixel = 0
    logoDot.ZIndex = 7
    logoDot.Parent = logoBox
    corner(logoDot, 14)
    local dotGrad = grad(logoDot, CONFIG.AccentColor, CONFIG.AccentAlt, 45)

    task.spawn(function()
        while logoDot.Parent do
            dotGrad.Rotation = (dotGrad.Rotation + 1.5) % 360
            task.wait(0.03)
        end
    end)

    local dotLbl = Instance.new("TextLabel")
    dotLbl.Size = UDim2.new(1, 0, 1, 0)
    dotLbl.BackgroundTransparency = 1
    dotLbl.Text = "R"
    dotLbl.TextColor3 = Color3.fromRGB(255,255,255)
    dotLbl.TextSize = 24
    dotLbl.Font = Enum.Font.GothamBold
    dotLbl.ZIndex = 8
    dotLbl.Parent = logoDot

    local brandName = Instance.new("TextLabel")
    brandName.Size = UDim2.new(1, -80, 0, 22)
    brandName.Position = UDim2.new(0, 76, 0, 24)
    brandName.BackgroundTransparency = 1
    brandName.Text = "RAKAUSUME"
    brandName.TextColor3 = THEME.Text
    brandName.TextSize = 16
    brandName.Font = Enum.Font.GothamBold
    brandName.TextXAlignment = Enum.TextXAlignment.Left
    brandName.ZIndex = 7
    brandName.Parent = logoBox

    local brandVer = Instance.new("TextLabel")
    brandVer.Size = UDim2.new(1, -80, 0, 14)
    brandVer.Position = UDim2.new(0, 76, 0, 46)
    brandVer.BackgroundTransparency = 1
    brandVer.Text = "v18 • premium"
    brandVer.TextColor3 = THEME.TextDim
    brandVer.TextSize = 10
    brandVer.Font = Enum.Font.Gotham
    brandVer.TextXAlignment = Enum.TextXAlignment.Left
    brandVer.ZIndex = 7
    brandVer.Parent = logoBox

    local avatar = Instance.new("ImageLabel")
    avatar.Size = UDim2.new(0, 44, 0, 44)
    avatar.Position = UDim2.new(1, -58, 0, 26)
    avatar.BackgroundColor3 = THEME.Bg4
    avatar.BorderSizePixel = 0
    avatar.Image = "rbxthumb://type=AvatarHeadShot&id="..player.UserId.."&w=150&h=150"
    avatar.ZIndex = 7
    avatar.Parent = logoBox
    corner(avatar, 22)
    stroke(avatar, CONFIG.AccentColor, 1.5, 0.2)

    -- live module panel
    local livePanel = Instance.new("Frame")
    livePanel.Size = UDim2.new(1, -24, 0, 34)
    livePanel.Position = UDim2.new(0, 12, 1, -46)
    livePanel.BackgroundColor3 = THEME.Bg3
    livePanel.BackgroundTransparency = 0.2
    livePanel.BorderSizePixel = 0
    livePanel.ZIndex = 7
    livePanel.Parent = sidebar
    corner(livePanel, 10)
    stroke(livePanel, CONFIG.AccentColor, 1, 0.5)

    local liveDot = Instance.new("Frame")
    liveDot.Size = UDim2.new(0, 8, 0, 8)
    liveDot.Position = UDim2.new(0, 10, 0.5, -4)
    liveDot.BackgroundColor3 = THEME.Green
    liveDot.BorderSizePixel = 0
    liveDot.ZIndex = 8
    liveDot.Parent = livePanel
    corner(liveDot, 4)

    task.spawn(function()
        while liveDot.Parent do
            tween(liveDot, 0.6, {BackgroundTransparency = 0.7})
            task.wait(0.6)
            tween(liveDot, 0.6, {BackgroundTransparency = 0})
            task.wait(0.6)
        end
    end)

    local liveLbl = Instance.new("TextLabel")
    liveLbl.Size = UDim2.new(1, -30, 1, 0)
    liveLbl.Position = UDim2.new(0, 24, 0, 0)
    liveLbl.BackgroundTransparency = 1
    liveLbl.Text = "0 modules active"
    liveLbl.TextColor3 = THEME.TextDim
    liveLbl.TextSize = 10
    liveLbl.Font = Enum.Font.GothamMedium
    liveLbl.TextXAlignment = Enum.TextXAlignment.Left
    liveLbl.ZIndex = 8
    liveLbl.Parent = livePanel

    local function updateLiveCount()
        local count = 0
        for _, v in pairs(CONFIG) do
            if v == true then count = count + 1 end
        end
        liveLbl.Text = tostring(count).." module"..(count == 1 and "" or "s").." active"
    end

    local navHolder = Instance.new("Frame")
    navHolder.Size = UDim2.new(1, -24, 1, -240)
    navHolder.Position = UDim2.new(0, 12, 0, 108)
    navHolder.BackgroundTransparency = 1
    navHolder.ZIndex = 6
    navHolder.Parent = sidebar
    list(navHolder, 4)

    local pages = {}
    local navBtns = {}

    local function makeNav(name, icon, label)
        local b = Instance.new("TextButton")
        b.Size = UDim2.new(1, 0, 0, 38)
        b.BackgroundColor3 = THEME.Bg2
        b.BackgroundTransparency = 0.2
        b.BorderSizePixel = 0
        b.Text = ""
        b.ZIndex = 7
        b.Parent = navHolder
        corner(b, 10)

        local iconLbl = Instance.new("TextLabel")
        iconLbl.Size = UDim2.new(0, 30, 1, 0)
        iconLbl.Position = UDim2.new(0, 10, 0, 0)
        iconLbl.BackgroundTransparency = 1
        iconLbl.Text = icon
        iconLbl.TextColor3 = THEME.TextDim
        iconLbl.TextSize = 16
        iconLbl.Font = Enum.Font.GothamBold
        iconLbl.ZIndex = 8
        iconLbl.Parent = b

        local textLbl = Instance.new("TextLabel")
        textLbl.Size = UDim2.new(1, -46, 1, 0)
        textLbl.Position = UDim2.new(0, 44, 0, 0)
        textLbl.BackgroundTransparency = 1
        textLbl.Text = label
        textLbl.TextColor3 = THEME.TextDim
        textLbl.TextSize = 13
        textLbl.Font = Enum.Font.GothamMedium
        textLbl.TextXAlignment = Enum.TextXAlignment.Left
        textLbl.ZIndex = 8
        textLbl.Parent = b

        local accentBar = Instance.new("Frame")
        accentBar.Size = UDim2.new(0, 3, 0, 20)
        accentBar.Position = UDim2.new(0, 0, 0.5, -10)
        accentBar.BackgroundColor3 = CONFIG.AccentColor
        accentBar.BorderSizePixel = 0
        accentBar.ZIndex = 8
        accentBar.Visible = false
        accentBar.Parent = b
        corner(accentBar, 3)

        b.MouseEnter:Connect(function()
            if not b:GetAttribute("active") then tween(b, 0.15, {BackgroundTransparency = 0.05}) end
        end)
        b.MouseLeave:Connect(function()
            if not b:GetAttribute("active") then tween(b, 0.15, {BackgroundTransparency = 0.2}) end
        end)
        navBtns[name] = {btn=b, icon=iconLbl, text=textLbl, accent=accentBar}
    end

    -- TOP BAR
    local topBar = Instance.new("Frame")
    topBar.Size = UDim2.new(1, -190, 0, 68)
    topBar.Position = UDim2.new(0, 190, 0, 0)
    topBar.BackgroundColor3 = THEME.Bg2
    topBar.BackgroundTransparency = 0.15
    topBar.BorderSizePixel = 0
    topBar.ZIndex = 5
    topBar.Parent = main
    local topFix = Instance.new("Frame")
    topFix.Size = UDim2.new(1, 0, 0, 18)
    topFix.Position = UDim2.new(0, 0, 1, -18)
    topFix.BackgroundColor3 = THEME.Bg2
    topFix.BackgroundTransparency = 0.15
    topFix.BorderSizePixel = 0
    topFix.ZIndex = 5
    topFix.Parent = topBar
    grad(topBar, Color3.fromRGB(24, 18, 42), THEME.Bg2, 0)

    local pageTitle = Instance.new("TextLabel")
    pageTitle.Size = UDim2.new(0, 320, 0, 22)
    pageTitle.Position = UDim2.new(0, 24, 0, 15)
    pageTitle.BackgroundTransparency = 1
    pageTitle.Text = "Main"
    pageTitle.TextColor3 = THEME.Text
    pageTitle.TextSize = 18
    pageTitle.Font = Enum.Font.GothamBold
    pageTitle.TextXAlignment = Enum.TextXAlignment.Left
    pageTitle.ZIndex = 6
    pageTitle.Parent = topBar

    local pageSub = Instance.new("TextLabel")
    pageSub.Size = UDim2.new(0, 320, 0, 14)
    pageSub.Position = UDim2.new(0, 24, 0, 40)
    pageSub.BackgroundTransparency = 1
    pageSub.Text = "toggle modules to start"
    pageSub.TextColor3 = THEME.TextDim
    pageSub.TextSize = 10
    pageSub.Font = Enum.Font.Gotham
    pageSub.TextXAlignment = Enum.TextXAlignment.Left
    pageSub.ZIndex = 6
    pageSub.Parent = topBar

    local searchBox = Instance.new("Frame")
    searchBox.Size = UDim2.new(0, 170, 0, 32)
    searchBox.Position = UDim2.new(1, -232, 0.5, -16)
    searchBox.BackgroundColor3 = THEME.Bg3
    searchBox.BorderSizePixel = 0
    searchBox.ZIndex = 6
    searchBox.Parent = topBar
    corner(searchBox, 16)
    stroke(searchBox, THEME.Stroke, 1, 0.6)

    local searchIcon = Instance.new("TextLabel")
    searchIcon.Size = UDim2.new(0, 26, 1, 0)
    searchIcon.Position = UDim2.new(0, 8, 0, 0)
    searchIcon.BackgroundTransparency = 1
    searchIcon.Text = "⌕"
    searchIcon.TextColor3 = THEME.TextDim
    searchIcon.TextSize = 14
    searchIcon.Font = Enum.Font.Gotham
    searchIcon.ZIndex = 7
    searchIcon.Parent = searchBox

    local searchIn = Instance.new("TextBox")
    searchIn.Size = UDim2.new(1, -38, 1, 0)
    searchIn.Position = UDim2.new(0, 34, 0, 0)
    searchIn.BackgroundTransparency = 1
    searchIn.Text = ""
    searchIn.PlaceholderText = "search..."
    searchIn.PlaceholderColor3 = THEME.TextDim2
    searchIn.TextColor3 = THEME.Text
    searchIn.TextSize = 11
    searchIn.Font = Enum.Font.Gotham
    searchIn.TextXAlignment = Enum.TextXAlignment.Left
    searchIn.ClearTextOnFocus = false
    searchIn.ZIndex = 7
    searchIn.Parent = searchBox

    local closeBtn = Instance.new("TextButton")
    closeBtn.Size = UDim2.new(0, 30, 0, 30)
    closeBtn.Position = UDim2.new(1, -38, 0.5, -15)
    closeBtn.BackgroundColor3 = Color3.fromRGB(55, 22, 32)
    closeBtn.BorderSizePixel = 0
    closeBtn.Text = "×"
    closeBtn.TextColor3 = THEME.Red
    closeBtn.TextSize = 18
    closeBtn.Font = Enum.Font.GothamBold
    closeBtn.ZIndex = 7
    closeBtn.Parent = topBar
    corner(closeBtn, 8)

    local minBtn = Instance.new("TextButton")
    minBtn.Size = UDim2.new(0, 30, 0, 30)
    minBtn.Position = UDim2.new(1, -74, 0.5, -15)
    minBtn.BackgroundColor3 = THEME.Bg3
    minBtn.BorderSizePixel = 0
    minBtn.Text = "—"
    minBtn.TextColor3 = THEME.TextDim
    minBtn.TextSize = 14
    minBtn.Font = Enum.Font.GothamBold
    minBtn.ZIndex = 7
    minBtn.Parent = topBar
    corner(minBtn, 8)

    local content = Instance.new("Frame")
    content.Size = UDim2.new(1, -190, 1, -128)
    content.Position = UDim2.new(0, 190, 0, 68)
    content.BackgroundTransparency = 1
    content.ZIndex = 5
    content.Parent = main
    pad(content, 22, 22, 22, 22)

    -- CARD
    local function makeCard(parent, opts)
        local card = Instance.new("Frame")
        card.Size = UDim2.new(1, 0, 0, 76)
        card.BackgroundColor3 = THEME.Bg2
        card.BackgroundTransparency = 0.15
        card.BorderSizePixel = 0
        card.ZIndex = 6
        card.Parent = parent
        corner(card, 14)
        local cardStroke = stroke(card, THEME.Stroke, 1, 0.65)
        card:SetAttribute("ModuleName", opts.name)

        local accent = Instance.new("Frame")
        accent.Size = UDim2.new(0, 3, 0, 40)
        accent.Position = UDim2.new(0, 0, 0.5, -20)
        accent.BackgroundColor3 = THEME.TextDim2
        accent.BorderSizePixel = 0
        accent.ZIndex = 7
        accent.Parent = card
        corner(accent, 3)

        local icon = Instance.new("Frame")
        icon.Size = UDim2.new(0, 44, 0, 44)
        icon.Position = UDim2.new(0, 18, 0.5, -22)
        icon.BackgroundColor3 = THEME.Bg3
        icon.BorderSizePixel = 0
        icon.ZIndex = 7
        icon.Parent = card
        corner(icon, 22)

        local iconLbl = Instance.new("TextLabel")
        iconLbl.Size = UDim2.new(1, 0, 1, 0)
        iconLbl.BackgroundTransparency = 1
        iconLbl.Text = opts.icon or "◆"
        iconLbl.TextColor3 = CONFIG.AccentColor
        iconLbl.TextSize = 20
        iconLbl.Font = Enum.Font.GothamBold
        iconLbl.ZIndex = 8
        iconLbl.Parent = icon

        local nameLbl = Instance.new("TextLabel")
        nameLbl.Size = UDim2.new(0, 320, 0, 20)
        nameLbl.Position = UDim2.new(0, 74, 0, 16)
        nameLbl.BackgroundTransparency = 1
        nameLbl.Text = opts.name
        nameLbl.TextColor3 = THEME.Text
        nameLbl.TextSize = 14
        nameLbl.Font = Enum.Font.GothamBold
        nameLbl.TextXAlignment = Enum.TextXAlignment.Left
        nameLbl.ZIndex = 7
        nameLbl.Parent = card

        local descLbl = Instance.new("TextLabel")
        descLbl.Size = UDim2.new(0, 380, 0, 16)
        descLbl.Position = UDim2.new(0, 74, 0, 38)
        descLbl.BackgroundTransparency = 1
        descLbl.Text = opts.desc or ""
        descLbl.TextColor3 = THEME.TextDim
        descLbl.TextSize = 11
        descLbl.Font = Enum.Font.Gotham
        descLbl.TextXAlignment = Enum.TextXAlignment.Left
        descLbl.ZIndex = 7
        descLbl.Parent = card

        local toggle = Instance.new("TextButton")
        toggle.Size = UDim2.new(0, 56, 0, 30)
        toggle.Position = UDim2.new(1, -74, 0.5, -15)
        toggle.BackgroundColor3 = opts.default and CONFIG.AccentColor or THEME.Bg3
        toggle.BorderSizePixel = 0
        toggle.Text = ""
        toggle.ZIndex = 7
        toggle.Parent = card
        corner(toggle, 15)

        local toggleStroke = stroke(toggle, CONFIG.AccentColor, 1.2, opts.default and 0.2 or 0.85)

        local knob = Instance.new("Frame")
        knob.Size = UDim2.new(0, 24, 0, 24)
        knob.Position = opts.default and UDim2.new(1, -27, 0.5, -12) or UDim2.new(0, 3, 0.5, -12)
        knob.BackgroundColor3 = Color3.fromRGB(255,255,255)
        knob.BorderSizePixel = 0
        knob.ZIndex = 8
        knob.Parent = toggle
        corner(knob, 12)

        local state = opts.default

        local function setState(s)
            state = s
            if s then
                tween(toggle, 0.28, {BackgroundColor3 = CONFIG.AccentColor})
                tween(knob, 0.28, {Position = UDim2.new(1, -27, 0.5, -12)})
                tween(accent, 0.2, {BackgroundColor3 = CONFIG.AccentColor})
                tween(iconLbl, 0.2, {TextColor3 = CONFIG.AccentColor})
                tween(toggleStroke, 0.2, {Color = CONFIG.AccentColor, Transparency = 0.2})
                tween(cardStroke, 0.2, {Color = CONFIG.AccentColor, Transparency = 0.4})
                task.spawn(function()
                    for i = 1, 3 do
                        tween(cardStroke, 0.15, {Transparency = 0.1})
                        task.wait(0.15)
                        tween(cardStroke, 0.15, {Transparency = 0.4})
                        task.wait(0.15)
                    end
                end)
            else
                tween(toggle, 0.28, {BackgroundColor3 = THEME.Bg3})
                tween(knob, 0.28, {Position = UDim2.new(0, 3, 0.5, -12)})
                tween(accent, 0.2, {BackgroundColor3 = THEME.TextDim2})
                tween(iconLbl, 0.2, {TextColor3 = CONFIG.AccentColor})
                tween(toggleStroke, 0.2, {Color = CONFIG.AccentColor, Transparency = 0.85})
                tween(cardStroke, 0.2, {Color = THEME.Stroke, Transparency = 0.65})
            end
        end

        card.MouseEnter:Connect(function() tween(card, 0.15, {BackgroundTransparency = 0.05}) end)
        card.MouseLeave:Connect(function() tween(card, 0.15, {BackgroundTransparency = 0.15}) end)

        toggle.MouseButton1Click:Connect(function()
            state = not state
            setState(state)
            updateLiveCount()
            if opts.callback then opts.callback(state) end
        end)

        toggle.MouseButton1Down:Connect(function()
            local ripple = Instance.new("Frame")
            ripple.Size = UDim2.new(0, 0, 0, 0)
            ripple.Position = UDim2.new(0.5, 0, 0.5, 0)
            ripple.AnchorPoint = Vector2.new(0.5, 0.5)
            ripple.BackgroundColor3 = Color3.fromRGB(255,255,255)
            ripple.BackgroundTransparency = 0.5
            ripple.BorderSizePixel = 0
            ripple.ZIndex = 8
            ripple.Parent = toggle
            corner(ripple, 100)
            tween(ripple, 0.55, {Size = UDim2.new(0, 110, 0, 110), BackgroundTransparency = 1})
            task.delay(0.55, function() ripple:Destroy() end)
        end)

        return {frame=card, set=setState}
    end

    local function makeSliderCard(parent, opts)
        local card = Instance.new("Frame")
        card.Size = UDim2.new(1, 0, 0, 88)
        card.BackgroundColor3 = THEME.Bg2
        card.BackgroundTransparency = 0.15
        card.BorderSizePixel = 0
        card.ZIndex = 6
        card.Parent = parent
        corner(card, 14)
        stroke(card, THEME.Stroke, 1, 0.65)
        card:SetAttribute("ModuleName", opts.name)

        local icon = Instance.new("Frame")
        icon.Size = UDim2.new(0, 36, 0, 36)
        icon.Position = UDim2.new(0, 18, 0, 14)
        icon.BackgroundColor3 = THEME.Bg3
        icon.BorderSizePixel = 0
        icon.ZIndex = 7
        icon.Parent = card
        corner(icon, 18)

        local iconLbl = Instance.new("TextLabel")
        iconLbl.Size = UDim2.new(1, 0, 1, 0)
        iconLbl.BackgroundTransparency = 1
        iconLbl.Text = opts.icon or "≡"
        iconLbl.TextColor3 = CONFIG.AccentColor
        iconLbl.TextSize = 16
        iconLbl.Font = Enum.Font.GothamBold
        iconLbl.ZIndex = 8
        iconLbl.Parent = icon

        local nameLbl = Instance.new("TextLabel")
        nameLbl.Size = UDim2.new(0, 360, 0, 18)
        nameLbl.Position = UDim2.new(0, 64, 0, 14)
        nameLbl.BackgroundTransparency = 1
        nameLbl.Text = opts.name
        nameLbl.TextColor3 = THEME.Text
        nameLbl.TextSize = 13
        nameLbl.Font = Enum.Font.GothamBold
        nameLbl.TextXAlignment = Enum.TextXAlignment.Left
        nameLbl.ZIndex = 7
        nameLbl.Parent = card

        local valLbl = Instance.new("TextLabel")
        valLbl.Size = UDim2.new(0, 110, 0, 18)
        valLbl.Position = UDim2.new(1, -120, 0, 14)
        valLbl.BackgroundTransparency = 1
        valLbl.Text = string.format("%.3f", opts.default)
        valLbl.TextColor3 = CONFIG.AccentColor
        valLbl.TextSize = 13
        valLbl.Font = Enum.Font.GothamBold
        valLbl.TextXAlignment = Enum.TextXAlignment.Right
        valLbl.ZIndex = 7
        valLbl.Parent = card

        local track = Instance.new("Frame")
        track.Size = UDim2.new(1, -36, 0, 6)
        track.Position = UDim2.new(0, 18, 0, 62)
        track.BackgroundColor3 = THEME.Bg3
        track.BorderSizePixel = 0
        track.ZIndex = 7
        track.Parent = card
        corner(track, 3)

        local fill = Instance.new("Frame")
        local initPct = (opts.default - opts.min) / (opts.max - opts.min)
        fill.Size = UDim2.new(initPct, 0, 1, 0)
        fill.BackgroundColor3 = CONFIG.AccentColor
        fill.BorderSizePixel = 0
        fill.ZIndex = 8
        fill.Parent = track
        corner(fill, 3)
        grad(fill, CONFIG.AccentColor, CONFIG.AccentAlt)

        local knob = Instance.new("Frame")
        knob.Size = UDim2.new(0, 16, 0, 16)
        knob.Position = UDim2.new(initPct, -8, 0.5, -8)
        knob.BackgroundColor3 = Color3.fromRGB(255,255,255)
        knob.BorderSizePixel = 0
        knob.ZIndex = 9
        knob.Parent = track
        corner(knob, 8)
        stroke(knob, CONFIG.AccentColor, 2, 0)

        local dragging = false
        local function update(input)
            local pos = math.clamp((input.Position.X - track.AbsolutePosition.X) / track.AbsoluteSize.X, 0, 1)
            fill.Size = UDim2.new(pos, 0, 1, 0)
            knob.Position = UDim2.new(pos, -8, 0.5, -8)
            local v = opts.min + (opts.max - opts.min) * pos
            valLbl.Text = string.format("%.3f", v)
            if opts.callback then opts.callback(v) end
        end
        track.InputBegan:Connect(function(input)
            if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
                dragging = true; update(input)
            end
        end)
        UserInputService.InputChanged:Connect(function(input)
            if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
                update(input)
            end
        end)
        UserInputService.InputEnded:Connect(function(input)
            if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
                dragging = false
            end
        end)
    end

    local function makeKeybindCard(parent, label, desc, which, getter)
        local card = Instance.new("Frame")
        card.Size = UDim2.new(1, 0, 0, 72)
        card.BackgroundColor3 = THEME.Bg2
        card.BackgroundTransparency = 0.15
        card.BorderSizePixel = 0
        card.ZIndex = 6
        card.Parent = parent
        corner(card, 14)
        stroke(card, THEME.Stroke, 1, 0.65)
        card:SetAttribute("ModuleName", label)

        local accent = Instance.new("Frame")
        accent.Size = UDim2.new(0, 3, 0, 36)
        accent.Position = UDim2.new(0, 0, 0.5, -18)
        accent.BackgroundColor3 = CONFIG.AccentColor
        accent.BorderSizePixel = 0
        accent.ZIndex = 7
        accent.Parent = card
        corner(accent, 3)

        local icon = Instance.new("Frame")
        icon.Size = UDim2.new(0, 42, 0, 42)
        icon.Position = UDim2.new(0, 18, 0.5, -21)
        icon.BackgroundColor3 = THEME.Bg3
        icon.BorderSizePixel = 0
        icon.ZIndex = 7
        icon.Parent = card
        corner(icon, 21)

        local iconLbl = Instance.new("TextLabel")
        iconLbl.Size = UDim2.new(1, 0, 1, 0)
        iconLbl.BackgroundTransparency = 1
        iconLbl.Text = "⌨"
        iconLbl.TextColor3 = CONFIG.AccentColor
        iconLbl.TextSize = 19
        iconLbl.Font = Enum.Font.GothamBold
        iconLbl.ZIndex = 8
        iconLbl.Parent = icon

        local nameLbl = Instance.new("TextLabel")
        nameLbl.Size = UDim2.new(0, 320, 0, 20)
        nameLbl.Position = UDim2.new(0, 72, 0, 14)
        nameLbl.BackgroundTransparency = 1
        nameLbl.Text = label
        nameLbl.TextColor3 = THEME.Text
        nameLbl.TextSize = 14
        nameLbl.Font = Enum.Font.GothamBold
        nameLbl.TextXAlignment = Enum.TextXAlignment.Left
        nameLbl.ZIndex = 7
        nameLbl.Parent = card

        local descLbl = Instance.new("TextLabel")
        descLbl.Size = UDim2.new(0, 380, 0, 16)
        descLbl.Position = UDim2.new(0, 72, 0, 36)
        descLbl.BackgroundTransparency = 1
        descLbl.Text = desc
        descLbl.TextColor3 = THEME.TextDim
        descLbl.TextSize = 11
        descLbl.Font = Enum.Font.Gotham
        descLbl.TextXAlignment = Enum.TextXAlignment.Left
        descLbl.ZIndex = 7
        descLbl.Parent = card

        local keyBtn = Instance.new("TextButton")
        keyBtn.Size = UDim2.new(0, 120, 0, 36)
        keyBtn.Position = UDim2.new(1, -136, 0.5, -18)
        keyBtn.BackgroundColor3 = THEME.Bg3
        keyBtn.BorderSizePixel = 0
        keyBtn.Text = keyName(getter())
        keyBtn.TextColor3 = THEME.Text
        keyBtn.TextSize = 12
        keyBtn.Font = Enum.Font.GothamBold
        keyBtn.ZIndex = 7
        keyBtn.Parent = card
        corner(keyBtn, 8)
        stroke(keyBtn, CONFIG.AccentColor, 1, 0.4)

        keyBtn.MouseEnter:Connect(function() tween(keyBtn, 0.15, {BackgroundColor3 = THEME.Bg4}) end)
        keyBtn.MouseLeave:Connect(function()
            if KEYBIND_STATE.listening ~= which then
                tween(keyBtn, 0.15, {BackgroundColor3 = THEME.Bg3})
            end
        end)
        keyBtn.MouseButton1Click:Connect(function() startListening(which) end)

        card.MouseEnter:Connect(function() tween(card, 0.15, {BackgroundTransparency = 0.05}) end)
        card.MouseLeave:Connect(function() tween(card, 0.15, {BackgroundTransparency = 0.15}) end)

        return keyBtn
    end

    local function makePage(name)
        local p = Instance.new("ScrollingFrame")
        p.Name = name
        p.Size = UDim2.new(1, 0, 1, 0)
        p.BackgroundTransparency = 1
        p.BorderSizePixel = 0
        p.ScrollBarThickness = 3
        p.ScrollBarImageColor3 = CONFIG.AccentColor
        p.CanvasSize = UDim2.new(0, 0, 0, 0)
        p.AutomaticCanvasSize = Enum.AutomaticSize.Y
        p.Visible = false
        p.ZIndex = 5
        pad(p, 4, 12, 0, 0)
        list(p, 10)
        pages[name] = p
        return p
    end

    makePage("Main")
    makePage("Combat")
    makePage("Visuals")
    makePage("Protection")
    makePage("Code")
    makePage("Wallpaper")
    makePage("Important")
    makePage("Settings")
    makePage("Update")
    makePage("About")

    -- MAIN
    local mp = pages["Main"]
    local s1 = Instance.new("TextLabel")
    s1.Size = UDim2.new(1, 0, 0, 22)
    s1.BackgroundTransparency = 1
    s1.Text = "RACING MODULES"
    s1.TextColor3 = THEME.TextDim
    s1.TextSize = 10
    s1.Font = Enum.Font.GothamBold
    s1.TextXAlignment = Enum.TextXAlignment.Left
    s1.Parent = mp

    local qteCard = makeCard(mp, {
        name = "Auto QTE",
        desc = "spams QTE (remote + prompt + keys + click)",
        icon = "⚡",
        default = CONFIG.AutoQTE,
        callback = enableAutoQTE,
    })
    qteToggleCardRef = qteCard.set
    makeSliderCard(mp, {
        name = "QTE Rate (sec)",
        icon = "⏱",
        min = 0.005, max = 0.1, default = CONFIG.QTERate,
        callback = function(v) CONFIG.QTERate = v end,
    })
    makeCard(mp, {
        name = "QTE Prompt Click",
        desc = "auto-fire proximity prompts in world",
        icon = "◎",
        default = CONFIG.QTEUsePromptClick,
        callback = function(s) CONFIG.QTEUsePromptClick = s end,
    })
    local staminaCard = makeCard(mp, {
        name = "Infinite Stamina",
        desc = "keeps stamina locked at maximum",
        icon = "∞",
        default = CONFIG.InfiniteStamina,
        callback = enableInfiniteStamina,
    })
    staminaToggleCardRef = staminaCard.set
    local speedCard = makeCard(mp, {
        name = "Speed Boost",
        desc = "multiplies walkspeed and jump power",
        icon = "»",
        default = CONFIG.SpeedBoost,
        callback = enableSpeedBoost,
    })
    speedToggleCardRef = speedCard.set
    makeSliderCard(mp, {
        name = "Speed Multiplier",
        icon = "≡",
        min = 1, max = 10, default = CONFIG.SpeedMultiplier,
        callback = function(v) CONFIG.SpeedMultiplier = v end,
    })

    -- COMBAT
    local cp = pages["Combat"]
    local s2 = Instance.new("TextLabel")
    s2.Size = UDim2.new(1, 0, 0, 22)
    s2.BackgroundTransparency = 1
    s2.Text = "COMBAT TOOLS"
    s2.TextColor3 = THEME.TextDim
    s2.TextSize = 10
    s2.Font = Enum.Font.GothamBold
    s2.TextXAlignment = Enum.TextXAlignment.Left
    s2.Parent = cp

    makeCard(cp, {
        name = "Remote Dump",
        desc = "print all remotes to F9 console",
        icon = "⌘",
        default = false,
        callback = function(s) if s then dumpRemotes(); notify("dumped to F9", "success") end end,
    })
    makeCard(cp, {
        name = "Infinite Boost",
        desc = "removes boost/spurt cooldown + key spam",
        icon = "✦",
        default = CONFIG.InfiniteBoost,
        callback = enableInfiniteBoost,
    })

    -- VISUALS
    local vp = pages["Visuals"]
    local s3 = Instance.new("TextLabel")
    s3.Size = UDim2.new(1, 0, 0, 22)
    s3.BackgroundTransparency = 1
    s3.Text = "VISUAL MODULES"
    s3.TextColor3 = THEME.TextDim
    s3.TextSize = 10
    s3.Font = Enum.Font.GothamBold
    s3.TextXAlignment = Enum.TextXAlignment.Left
    s3.Parent = vp

    local espCard = makeCard(vp, {
        name = "Player ESP",
        desc = "shows enemy stamina + uma character",
        icon = "◉",
        default = CONFIG.PlayerESP,
        callback = enablePlayerESP,
    })
    espToggleCardRef = espCard.set
    makeCard(vp, {
        name = "ESP RGB Border",
        desc = "animated rainbow outline on ESP",
        icon = "◈",
        default = CONFIG.ESPRGBBorder,
        callback = enableESPRGB,
    })
    makeCard(vp, {
        name = "Fullbright",
        desc = "removes dark lighting",
        icon = "☀",
        default = false,
        callback = function(s)
            if s then
                Lighting.Ambient = Color3.fromRGB(200,200,200)
                Lighting.Brightness = 3
            else
                Lighting.Ambient = Color3.fromRGB(70,70,70)
                Lighting.Brightness = 1
            end
            notify("Fullbright "..(s and "on" or "off"), s and "success" or "info")
        end,
    })
    makeCard(vp, {
        name = "Deep Stamina Scan",
        desc = "gc-based scan for enemy stamina (heavier)",
        icon = "🔍",
        default = CONFIG.DeepStamScan,
        callback = function(s) CONFIG.DeepStamScan = s end,
    })

    -- PROTECTION
    local pp = pages["Protection"]
    local sP = Instance.new("TextLabel")
    sP.Size = UDim2.new(1, 0, 0, 22)
    sP.BackgroundTransparency = 1
    sP.Text = "SAFETY MODULES"
    sP.TextColor3 = THEME.TextDim
    sP.TextSize = 10
    sP.Font = Enum.Font.GothamBold
    sP.TextXAlignment = Enum.TextXAlignment.Left
    sP.Parent = pp

    makeCard(pp, {
        name = "Anti-AFK",
        desc = "prevents idle kick from inactivity",
        icon = "☕",
        default = CONFIG.AntiAFK,
        callback = enableAntiAFK,
    })
    makeCard(pp, {
        name = "Anti-Kick",
        desc = "blocks kick/ban remote attempts",
        icon = "🛡",
        default = CONFIG.AntiKick,
        callback = enableAntiKick,
    })
    makeCard(pp, {
        name = "Anti-Staff",
        desc = "detects staff + auto-disables modules",
        icon = "👁",
        default = CONFIG.AntiStaff,
        callback = enableAntiStaff,
    })

    -- CODE
    local codep = pages["Code"]
    local codeHeader = Instance.new("TextLabel")
    codeHeader.Size = UDim2.new(1, 0, 0, 22)
    codeHeader.BackgroundTransparency = 1
    codeHeader.Text = "CODE CONSOLE"
    codeHeader.TextColor3 = THEME.TextDim
    codeHeader.TextSize = 10
    codeHeader.Font = Enum.Font.GothamBold
    codeHeader.TextXAlignment = Enum.TextXAlignment.Left
    codeHeader.Parent = codep

    local codeHint = Instance.new("TextLabel")
    codeHint.Size = UDim2.new(1, 0, 0, 16)
    codeHint.BackgroundTransparency = 1
    codeHint.Text = "type a code below..."
    codeHint.TextColor3 = THEME.TextDim2
    codeHint.TextSize = 10
    codeHint.Font = Enum.Font.Gotham
    codeHint.TextXAlignment = Enum.TextXAlignment.Left
    codeHint.Parent = codep

    local codeBox = Instance.new("TextBox")
    codeBox.Size = UDim2.new(1, 0, 0, 42)
    codeBox.BackgroundColor3 = THEME.Bg2
    codeBox.BackgroundTransparency = 0.15
    codeBox.BorderSizePixel = 0
    codeBox.Text = ""
    codeBox.PlaceholderText = "enter code..."
    codeBox.PlaceholderColor3 = Color3.fromRGB(90, 85, 120)
    codeBox.TextColor3 = THEME.Text
    codeBox.TextSize = 14
    codeBox.Font = Enum.Font.Gotham
    codeBox.ClearTextOnFocus = false
    codeBox.Parent = codep
    codeBox.ZIndex = 6
    corner(codeBox, 10)
    stroke(codeBox, THEME.Stroke, 1, 0.6)

    local codeStatus = Instance.new("TextLabel")
    codeStatus.Size = UDim2.new(1, 0, 0, 18)
    codeStatus.BackgroundTransparency = 1
    codeStatus.Text = ""
    codeStatus.TextColor3 = CONFIG.AccentColor
    codeStatus.TextSize = 11
    codeStatus.Font = Enum.Font.Gotham
    codeStatus.TextXAlignment = Enum.TextXAlignment.Left
    codeStatus.Parent = codep

    local codeSubmit = Instance.new("TextButton")
    codeSubmit.Size = UDim2.new(1, 0, 0, 40)
    codeSubmit.BackgroundColor3 = CONFIG.AccentColor
    codeSubmit.BorderSizePixel = 0
    codeSubmit.Text = "RUN CODE"
    codeSubmit.TextColor3 = Color3.fromRGB(15, 15, 20)
    codeSubmit.TextSize = 13
    codeSubmit.Font = Enum.Font.GothamBold
    codeSubmit.Parent = codep
    corner(codeSubmit, 10)

    codeSubmit.MouseEnter:Connect(function() tween(codeSubmit, 0.15, {BackgroundColor3 = CONFIG.AccentAlt}) end)
    codeSubmit.MouseLeave:Connect(function() tween(codeSubmit, 0.15, {BackgroundColor3 = CONFIG.AccentColor}) end)

    codeSubmit.MouseButton1Click:Connect(function()
        local code = codeBox.Text
        if code == "" then return end
        local result = runCode(code)
        if result == nil then
            codeStatus.Text = "invalid code: "..code
            codeStatus.TextColor3 = THEME.Red
        elseif result == true then
            codeStatus.Text = code.." activated"
            codeStatus.TextColor3 = THEME.Green
            if code ~= "iloveoguri1023" then notify(code.." on", "success") end
        else
            codeStatus.Text = code.." deactivated"
            codeStatus.TextColor3 = THEME.Yellow
            notify(code.." off", "info")
        end
        codeBox.Text = ""
        task.delay(2.5, function()
            if codeStatus.Text:find(code) then codeStatus.Text = "" end
        end)
    end)

    -- WALLPAPER PAGE
    local wp = pages["Wallpaper"]
    local wpHeader = Instance.new("TextLabel")
    wpHeader.Size = UDim2.new(1, 0, 0, 22)
    wpHeader.BackgroundTransparency = 1
    wpHeader.Text = "WALLPAPER CONFIGURATION"
    wpHeader.TextColor3 = THEME.TextDim
    wpHeader.TextSize = 10
    wpHeader.Font = Enum.Font.GothamBold
    wpHeader.TextXAlignment = Enum.TextXAlignment.Left
    wpHeader.Parent = wp

    local presetRow = Instance.new("Frame")
    presetRow.Size = UDim2.new(1, 0, 0, 94)
    presetRow.BackgroundColor3 = THEME.Bg2
    presetRow.BackgroundTransparency = 0.15
    presetRow.BorderSizePixel = 0
    presetRow.Parent = wp
    presetRow.ZIndex = 6
    corner(presetRow, 12)
    stroke(presetRow, THEME.Stroke, 1, 0.6)
    presetRow:SetAttribute("ModuleName", "Wallpaper Presets")

    local presetTitle = Instance.new("TextLabel")
    presetTitle.Size = UDim2.new(1, -20, 0, 16)
    presetTitle.Position = UDim2.new(0, 14, 0, 8)
    presetTitle.BackgroundTransparency = 1
    presetTitle.Text = "PRESETS"
    presetTitle.TextColor3 = THEME.Text
    presetTitle.TextSize = 11
    presetTitle.Font = Enum.Font.GothamBold
    presetTitle.TextXAlignment = Enum.TextXAlignment.Left
    presetTitle.ZIndex = 7
    presetTitle.Parent = presetRow

    local presetList = Instance.new("Frame")
    presetList.Size = UDim2.new(1, -28, 0, 56)
    presetList.Position = UDim2.new(0, 14, 0, 30)
    presetList.BackgroundTransparency = 1
    presetList.ZIndex = 7
    presetList.Parent = presetRow
    local presetLayout = Instance.new("UIListLayout")
    presetLayout.FillDirection = Enum.FillDirection.Horizontal
    presetLayout.Padding = UDim.new(0, 8)
    presetLayout.SortOrder = Enum.SortOrder.LayoutOrder
    presetLayout.Parent = presetList

    local function makeWallBtn(label, src)
        local b = Instance.new("TextButton")
        b.Size = UDim2.new(0, 110, 0, 50)
        b.BackgroundColor3 = THEME.Bg3
        b.BorderSizePixel = 0
        b.Text = label
        b.TextColor3 = THEME.Text
        b.TextSize = 11
        b.Font = Enum.Font.GothamBold
        b.ZIndex = 8
        b.Parent = presetList
        corner(b, 8)
        stroke(b, CONFIG.AccentColor, 1, 0.4)
        b.MouseEnter:Connect(function() tween(b, 0.15, {BackgroundColor3 = THEME.Bg4}) end)
        b.MouseLeave:Connect(function() tween(b, 0.15, {BackgroundColor3 = THEME.Bg3}) end)
        b.MouseButton1Click:Connect(function() applyWallpaper(src) end)
    end

    makeWallBtn("Default", "default")
    makeWallBtn("Oguri 1", "oguri1")
    makeWallBtn("Oguri 2", "oguri2")
    makeWallBtn("Oguri 3", "oguri3")

    local urlBox = Instance.new("TextBox")
    urlBox.Size = UDim2.new(1, 0, 0, 42)
    urlBox.BackgroundColor3 = THEME.Bg2
    urlBox.BackgroundTransparency = 0.15
    urlBox.BorderSizePixel = 0
    urlBox.Text = ""
    urlBox.PlaceholderText = "paste image url or rbxassetid://..."
    urlBox.PlaceholderColor3 = THEME.TextDim2
    urlBox.TextColor3 = THEME.Text
    urlBox.TextSize = 12
    urlBox.Font = Enum.Font.Gotham
    urlBox.ClearTextOnFocus = false
    urlBox.ZIndex = 6
    urlBox.Parent = wp
    corner(urlBox, 10)
    stroke(urlBox, THEME.Stroke, 1, 0.6)
    urlBox:SetAttribute("ModuleName", "Custom Wallpaper URL")

    local urlApply = Instance.new("TextButton")
    urlApply.Size = UDim2.new(1, 0, 0, 38)
    urlApply.BackgroundColor3 = CONFIG.AccentColor
    urlApply.BorderSizePixel = 0
    urlApply.Text = "APPLY CUSTOM URL"
    urlApply.TextColor3 = Color3.fromRGB(15,15,20)
    urlApply.TextSize = 12
    urlApply.Font = Enum.Font.GothamBold
    urlApply.ZIndex = 6
    urlApply.Parent = wp
    corner(urlApply, 10)
    urlApply:SetAttribute("ModuleName", "Apply Custom")
    urlApply.MouseButton1Click:Connect(function()
        local url = urlBox.Text
        if url == "" then return end
        applyWallpaper(url)
    end)

    -- IMPORTANT
    local ip = pages["Important"]
    local iTitle = Instance.new("TextLabel")
    iTitle.Size = UDim2.new(1, 0, 0, 22)
    iTitle.BackgroundTransparency = 1
    iTitle.Text = "IMPORTANT"
    iTitle.TextColor3 = THEME.Red
    iTitle.TextSize = 10
    iTitle.Font = Enum.Font.GothamBold
    iTitle.TextXAlignment = Enum.TextXAlignment.Left
    iTitle.Parent = ip

    local impCard = Instance.new("Frame")
    impCard.Size = UDim2.new(1, 0, 0, 150)
    impCard.BackgroundColor3 = THEME.Bg2
    impCard.BackgroundTransparency = 0.15
    impCard.BorderSizePixel = 0
    impCard.ZIndex = 6
    impCard.Parent = ip
    corner(impCard, 12)
    stroke(impCard, THEME.Red, 1.4, 0.2)
    impCard:SetAttribute("ModuleName", "Important Notice")

    local impIcon = Instance.new("Frame")
    impIcon.Size = UDim2.new(0, 46, 0, 46)
    impIcon.Position = UDim2.new(0, 16, 0, 16)
    impIcon.BackgroundColor3 = THEME.Red
    impIcon.BorderSizePixel = 0
    impIcon.ZIndex = 7
    impIcon.Parent = impCard
    corner(impIcon, 23)

    local impIconLbl = Instance.new("TextLabel")
    impIconLbl.Size = UDim2.new(1, 0, 1, 0)
    impIconLbl.BackgroundTransparency = 1
    impIconLbl.Text = "!"
    impIconLbl.TextColor3 = Color3.fromRGB(255,255,255)
    impIconLbl.TextSize = 24
    impIconLbl.Font = Enum.Font.GothamBold
    impIconLbl.ZIndex = 8
    impIconLbl.Parent = impIcon

    local impHead = Instance.new("TextLabel")
    impHead.Size = UDim2.new(1, -80, 0, 22)
    impHead.Position = UDim2.new(0, 74, 0, 18)
    impHead.BackgroundTransparency = 1
    impHead.Text = "READ THIS"
    impHead.TextColor3 = THEME.Text
    impHead.TextSize = 14
    impHead.Font = Enum.Font.GothamBold
    impHead.TextXAlignment = Enum.TextXAlignment.Left
    impHead.ZIndex = 7
    impHead.Parent = impCard

    local impBody = Instance.new("TextLabel")
    impBody.Size = UDim2.new(1, -32, 0, 90)
    impBody.Position = UDim2.new(0, 16, 0, 70)
    impBody.BackgroundTransparency = 1
    impBody.Text = "this script only for developer if you buying this from a person you have been scammed"
    impBody.TextColor3 = THEME.TextDim
    impBody.TextSize = 13
    impBody.Font = Enum.Font.Gotham
    impBody.TextXAlignment = Enum.TextXAlignment.Left
    impBody.TextYAlignment = Enum.TextYAlignment.Top
    impBody.TextWrapped = true
    impBody.ZIndex = 7
    impBody.Parent = impCard

    -- SETTINGS
    local sp = pages["Settings"]
    local s4 = Instance.new("TextLabel")
    s4.Size = UDim2.new(1, 0, 0, 22)
    s4.BackgroundTransparency = 1
    s4.Text = "UI SETTINGS"
    s4.TextColor3 = THEME.TextDim
    s4.TextSize = 10
    s4.Font = Enum.Font.GothamBold
    s4.TextXAlignment = Enum.TextXAlignment.Left
    s4.Parent = sp

    makeSliderCard(sp, {
        name = "UI Transparency",
        icon = "◐",
        min = 0, max = 0.5, default = 0,
        callback = function(v)
            main.BackgroundTransparency = v
            sidebar.BackgroundTransparency = v + 0.15
            topBar.BackgroundTransparency = v + 0.15
        end,
    })

    local accentLbl = Instance.new("TextLabel")
    accentLbl.Size = UDim2.new(1, 0, 0, 22)
    accentLbl.BackgroundTransparency = 1
    accentLbl.Text = "ACCENT COLOR"
    accentLbl.TextColor3 = THEME.TextDim
    accentLbl.TextSize = 10
    accentLbl.Font = Enum.Font.GothamBold
    accentLbl.TextXAlignment = Enum.TextXAlignment.Left
    accentLbl.Parent = sp

    local accentRow = Instance.new("Frame")
    accentRow.Size = UDim2.new(1, 0, 0, 64)
    accentRow.BackgroundColor3 = THEME.Bg2
    accentRow.BackgroundTransparency = 0.15
    accentRow.BorderSizePixel = 0
    accentRow.ZIndex = 6
    accentRow.Parent = sp
    corner(accentRow, 12)
    stroke(accentRow, THEME.Stroke, 1, 0.6)
    accentRow:SetAttribute("ModuleName", "Accent Picker")

    local accentRowLayout = Instance.new("UIListLayout")
    accentRowLayout.FillDirection = Enum.FillDirection.Horizontal
    accentRowLayout.Padding = UDim.new(0, 10)
    accentRowLayout.SortOrder = Enum.SortOrder.LayoutOrder
    accentRowLayout.VerticalAlignment = Enum.VerticalAlignment.Center
    accentRowLayout.HorizontalAlignment = Enum.HorizontalAlignment.Center
    accentRowLayout.Parent = accentRow

    for name, preset in pairs(ACCENT_PRESETS) do
        local btn = Instance.new("TextButton")
        btn.Size = UDim2.new(0, 36, 0, 36)
        btn.BackgroundColor3 = preset.main
        btn.BorderSizePixel = 0
        btn.Text = ""
        btn.ZIndex = 7
        btn.Parent = accentRow
        corner(btn, 18)
        stroke(btn, Color3.fromRGB(255,255,255), 1.5, 0.6)
        btn.MouseEnter:Connect(function() tween(btn, 0.15, {Size = UDim2.new(0, 42, 0, 42)}) end)
        btn.MouseLeave:Connect(function() tween(btn, 0.15, {Size = UDim2.new(0, 36, 0, 36)}) end)
        btn.MouseButton1Click:Connect(function()
            CONFIG.AccentName = name
            CONFIG.AccentColor = preset.main
            CONFIG.AccentAlt = preset.alt
            mainStroke.Color = preset.main
            dotGrad.Color = ColorSequence.new(preset.main, preset.alt)
            logoGrad.Color = ColorSequence.new(preset.main, preset.alt)
            for _, p in pairs(pages) do p.ScrollBarImageColor3 = preset.main end
            notify("accent: "..name, "success")
        end)
    end

    local kbSectionLbl = Instance.new("TextLabel")
    kbSectionLbl.Size = UDim2.new(1, 0, 0, 22)
    kbSectionLbl.BackgroundTransparency = 1
    kbSectionLbl.Text = "KEYBINDS"
    kbSectionLbl.TextColor3 = THEME.TextDim
    kbSectionLbl.TextSize = 10
    kbSectionLbl.Font = Enum.Font.GothamBold
    kbSectionLbl.TextXAlignment = Enum.TextXAlignment.Left
    kbSectionLbl.Parent = sp

    local staminaKeyBtn = makeKeybindCard(sp, "Stamina Toggle", "key to open/close infinite stamina", "stamina", function() return CONFIG.KeybindStamina end)
    local menuKeyBtn = makeKeybindCard(sp, "Menu Toggle", "key to open/close this menu", "menu", function() return CONFIG.KeybindMenu end)

    KEYBIND_STATE.uiRefs = { staminaBtn = staminaKeyBtn, menuBtn = menuKeyBtn }
    updateKeybindUI()

    -- UPDATE
    local up = pages["Update"]
    local uTitle = Instance.new("TextLabel")
    uTitle.Size = UDim2.new(1, 0, 0, 22)
    uTitle.BackgroundTransparency = 1
    uTitle.Text = "UPDATE NOTICE"
    uTitle.TextColor3 = THEME.TextDim
    uTitle.TextSize = 10
    uTitle.Font = Enum.Font.GothamBold
    uTitle.TextXAlignment = Enum.TextXAlignment.Left
    uTitle.Parent = up

    local updateCard = Instance.new("Frame")
    updateCard.Size = UDim2.new(1, 0, 0, 130)
    updateCard.BackgroundColor3 = THEME.Bg2
    updateCard.BackgroundTransparency = 0.15
    updateCard.BorderSizePixel = 0
    updateCard.ZIndex = 6
    updateCard.Parent = up
    corner(updateCard, 12)
    stroke(updateCard, CONFIG.AccentColor, 1.2, 0.3)
    updateCard:SetAttribute("ModuleName", "Update Notice")

    local uIcon = Instance.new("Frame")
    uIcon.Size = UDim2.new(0, 42, 0, 42)
    uIcon.Position = UDim2.new(0, 16, 0, 16)
    uIcon.BackgroundColor3 = CONFIG.AccentColor
    uIcon.BorderSizePixel = 0
    uIcon.ZIndex = 7
    uIcon.Parent = updateCard
    corner(uIcon, 12)
    grad(uIcon, CONFIG.AccentColor, CONFIG.AccentAlt, 45)

    local uIconLbl = Instance.new("TextLabel")
    uIconLbl.Size = UDim2.new(1, 0, 1, 0)
    uIconLbl.BackgroundTransparency = 1
    uIconLbl.Text = "★"
    uIconLbl.TextColor3 = Color3.fromRGB(255,255,255)
    uIconLbl.TextSize = 20
    uIconLbl.Font = Enum.Font.GothamBold
    uIconLbl.ZIndex = 8
    uIconLbl.Parent = uIcon

    local uHead = Instance.new("TextLabel")
    uHead.Size = UDim2.new(1, -80, 0, 20)
    uHead.Position = UDim2.new(0, 70, 0, 16)
    uHead.BackgroundTransparency = 1
    uHead.Text = "Upcoming Key System"
    uHead.TextColor3 = THEME.Text
    uHead.TextSize = 14
    uHead.Font = Enum.Font.GothamBold
    uHead.TextXAlignment = Enum.TextXAlignment.Left
    uHead.ZIndex = 7
    uHead.Parent = updateCard

    local uBody = Instance.new("TextLabel")
    uBody.Size = UDim2.new(1, -32, 0, 60)
    uBody.Position = UDim2.new(0, 16, 0, 62)
    uBody.BackgroundTransparency = 1
    uBody.Text = "on new update there is gonna be a key and key is BAITING"
    uBody.TextColor3 = THEME.TextDim
    uBody.TextSize = 12
    uBody.Font = Enum.Font.Gotham
    uBody.TextXAlignment = Enum.TextXAlignment.Left
    uBody.TextYAlignment = Enum.TextYAlignment.Top
    uBody.TextWrapped = true
    uBody.ZIndex = 7
    uBody.Parent = updateCard

    -- ABOUT
    local ap = pages["About"]
    local aboutCard = Instance.new("Frame")
    aboutCard.Size = UDim2.new(1, 0, 0, 200)
    aboutCard.BackgroundColor3 = THEME.Bg2
    aboutCard.BackgroundTransparency = 0.15
    aboutCard.BorderSizePixel = 0
    aboutCard.ZIndex = 6
    aboutCard.Parent = ap
    corner(aboutCard, 12)
    stroke(aboutCard, CONFIG.AccentColor, 1, 0.4)

    local aboutLogo = Instance.new("Frame")
    aboutLogo.Size = UDim2.new(0, 64, 0, 64)
    aboutLogo.Position = UDim2.new(0.5, -32, 0, 24)
    aboutLogo.BackgroundColor3 = CONFIG.AccentColor
    aboutLogo.BorderSizePixel = 0
    aboutLogo.ZIndex = 7
    aboutLogo.Parent = aboutCard
    corner(aboutLogo, 18)
    grad(aboutLogo, CONFIG.AccentColor, CONFIG.AccentAlt, 45)

    local aboutR = Instance.new("TextLabel")
    aboutR.Size = UDim2.new(1, 0, 1, 0)
    aboutR.BackgroundTransparency = 1
    aboutR.Text = "R"
    aboutR.TextColor3 = Color3.fromRGB(255,255,255)
    aboutR.TextSize = 32
    aboutR.Font = Enum.Font.GothamBold
    aboutR.ZIndex = 8
    aboutR.Parent = aboutLogo

    local aboutName = Instance.new("TextLabel")
    aboutName.Size = UDim2.new(1, 0, 0, 26)
    aboutName.Position = UDim2.new(0, 0, 0, 100)
    aboutName.BackgroundTransparency = 1
    aboutName.Text = "RAKAUSUME"
    aboutName.TextColor3 = THEME.Text
    aboutName.TextSize = 20
    aboutName.Font = Enum.Font.GothamBold
    aboutName.ZIndex = 7
    aboutName.Parent = aboutCard

    local aboutVer = Instance.new("TextLabel")
    aboutVer.Size = UDim2.new(1, 0, 0, 20)
    aboutVer.Position = UDim2.new(0, 0, 0, 126)
    aboutVer.BackgroundTransparency = 1
    aboutVer.Text = "UmaRacing Exploit Kit v18"
    aboutVer.TextColor3 = THEME.TextDim
    aboutVer.TextSize = 12
    aboutVer.Font = Enum.Font.Gotham
    aboutVer.ZIndex = 7
    aboutVer.Parent = aboutCard

    local aboutTag = Instance.new("TextLabel")
    aboutTag.Size = UDim2.new(1, 0, 0, 20)
    aboutTag.Position = UDim2.new(0, 0, 0, 154)
    aboutTag.BackgroundTransparency = 1
    aboutTag.Text = "6767 • gng"
    aboutTag.TextColor3 = CONFIG.AccentColor
    aboutTag.TextSize = 11
    aboutTag.Font = Enum.Font.GothamBold
    aboutTag.ZIndex = 7
    aboutTag.Parent = aboutCard

    -- NAV
    makeNav("Main", "◆", "Main")
    makeNav("Combat", "⚔", "Combat")
    makeNav("Visuals", "◉", "Visuals")
    makeNav("Protection", "🛡", "Protection")
    makeNav("Code", "⌨", "Code")
    makeNav("Wallpaper", "🖼", "Wallpaper")
    makeNav("Important", "!", "Important")
    makeNav("Settings", "⚙", "Settings")
    makeNav("Update", "★", "Update")
    makeNav("About", "◇", "About")

    if navBtns["Wallpaper"] then navBtns["Wallpaper"].btn.Visible = false end

    navBtnsRef = navBtns
    pagesRef = pages

    local function switchPage(name)
        if name == "Wallpaper" and not WALLPAPER_STATE.unlocked then return end
        for n, p in pairs(pages) do
            if n == name then
                p.Parent = content
                p.Visible = true
                p.Position = UDim2.new(0, 20, 0, 0)
                tween(p, 0.3, {Position = UDim2.new(0, 0, 0, 0)})
            else
                p.Visible = false
            end
        end
        for n, t in pairs(navBtns) do
            local active = (n == name)
            t.btn:SetAttribute("active", active)
            t.accent.Visible = active
            if active then
                tween(t.btn, 0.2, {BackgroundColor3 = CONFIG.AccentColor, BackgroundTransparency = 0})
                tween(t.icon, 0.2, {TextColor3 = Color3.fromRGB(255,255,255)})
                tween(t.text, 0.2, {TextColor3 = Color3.fromRGB(255,255,255)})
            else
                tween(t.btn, 0.2, {BackgroundColor3 = THEME.Bg2, BackgroundTransparency = 0.2})
                tween(t.icon, 0.2, {TextColor3 = THEME.TextDim})
                tween(t.text, 0.2, {TextColor3 = THEME.TextDim})
            end
        end
        pageTitle.Text = name
        pageSub.Text = name == "Main" and "toggle modules to start"
            or name == "Combat" and "combat tools"
            or name == "Visuals" and "visual modules"
            or name == "Protection" and "safety modules"
            or name == "Code" and "enter codes"
            or name == "Wallpaper" and "dev wallpaper config"
            or name == "Important" and "read before use"
            or name == "Settings" and "configure ui"
            or name == "Update" and "what's coming next"
            or "about this kit"
    end

    for n, t in pairs(navBtns) do
        t.btn.MouseButton1Click:Connect(function() switchPage(n) end)
    end
    switchPage("Main")

    searchIn:GetPropertyChangedSignal("Text"):Connect(function()
        local q = searchIn.Text:lower()
        for _, p in pairs(pages) do
            for _, c in pairs(p:GetChildren()) do
                if c:IsA("Frame") and c:GetAttribute("ModuleName") then
                    local n = tostring(c:GetAttribute("ModuleName")):lower()
                    c.Visible = q == "" or n:find(q) ~= nil
                end
            end
        end
    end)

    closeBtn.MouseButton1Click:Connect(function()
        CONFIG.AutoQTE = false
        CONFIG.InfiniteStamina = false
        CONFIG.SpeedBoost = false
        CONFIG.InfiniteBoost = false
        CONFIG.PlayerESP = false
        CONFIG.ESPRGBBorder = false
        CONFIG.AntiAFK = false
        CONFIG.AntiKick = false
        CONFIG.AntiStaff = false
        if speedConn then speedConn:Disconnect() end
        if stamConn then stamConn:Disconnect() end
        for _, c in ipairs(staminaConns) do if c then c:Disconnect() end end
        if stamThread then task.cancel(stamThread) end
        if qteThread then task.cancel(qteThread) end
        if espRGBThread then task.cancel(espRGBThread) end
        if antiAfkConn then antiAfkConn:Disconnect() end
        if antiStaffConn then antiStaffConn:Disconnect() end
        for plr, _ in pairs(espEntries) do removeESP(plr) end
        if espFolder then espFolder:Destroy() end
        tween(main, 0.3, {Size = UDim2.new(0, 700, 0, 0), BackgroundTransparency = 1})
        task.wait(0.3)
        gui:Destroy()
    end)

    local minimized = false
    minBtn.MouseButton1Click:Connect(function()
        minimized = not minimized
        tween(main, 0.4, {Size = minimized and UDim2.new(0, 700, 0, 68) or UDim2.new(0, 700, 0, 480)})
        sidebar.Visible = not minimized
        content.Visible = not minimized
    end)

    local drag, ds, sp2
    topBar.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
            drag = true; ds = input.Position; sp2 = main.Position
        end
    end)
    UserInputService.InputChanged:Connect(function(input)
        if drag and input.UserInputType == Enum.UserInputType.MouseMovement then
            local d = input.Position - ds
            main.Position = UDim2.new(sp2.X.Scale, sp2.X.Offset + d.X, sp2.Y.Scale, sp2.Y.Offset + d.Y)
        end
    end)
    UserInputService.InputEnded:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then drag = false end
    end)

    local uiVisible = true
    UserInputService.InputBegan:Connect(function(input, gpe)
        if gpe then return end
        if input.UserInputType ~= Enum.UserInputType.Keyboard then return end
        if KEYBIND_STATE.listening then return end
        if input.KeyCode == CONFIG.KeybindMenu then
            uiVisible = not uiVisible
            main.Visible = uiVisible
        end
        if input.KeyCode == CONFIG.KeybindStamina then
            local newState = not CONFIG.InfiniteStamina
            enableInfiniteStamina(newState)
            if staminaToggleCardRef then staminaToggleCardRef(newState) end
        end
    end)

    updateLiveCount()
    notify("RAKAUSUME v18 loaded — 6767", "success", 4)
end

-- ============================================
-- RESPAWN
-- ============================================
player.CharacterAdded:Connect(function(c)
    character = c
    humanoid = c:WaitForChild("Humanoid")
    rootPart = c:WaitForChild("HumanoidRootPart")
    if CONFIG.SpeedBoost then task.wait(1); applySpeed() end
    if CONFIG.InfiniteStamina then task.wait(1); scanForStamina() end
end)

startRemoteSniffer()
bootSplash()
buildUI()
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 Uma Racing 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: Uma Racing
  • Developer: uma racing Community
  • Maturity: Moderate (Age 9+)
  • Genre: Sports & Racing
  • Subgenre: Racing

Frequently Asked Questions

What is a Uma Racing script?

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

What features does this Uma Racing script include?

Different scripts contain different code. This version includes: Infinite Stamina, Auto QTE, Speed Modifer, QTE Promt Click, Fullbright, Anti AFK.

How do you use the Uma Racing 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 Uma Racing 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 Uma Racing 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.