Richie Hub
Key RequiredUniversal

Richie Hub

Universal ScriptWspahmedWspahmed 29 views 2 executesUpdated Oct 2, 2026
5.0/ 5(1 votes)
10100% Positive
Lua Script•4616 lines (160750 chars)
-- Richie Hub | Full Script
local P=game:GetService("Players")
local U=game:GetService("UserInputService")
local R=game:GetService("RunService")
local T=game:GetService("TweenService")
local W=game:GetService("Workspace")
local L=game:GetService("Lighting")
local C=W.CurrentCamera
local LP=P.LocalPlayer

local pg
local ok,h=pcall(function() return gethui() end)
pg=ok and h or LP:WaitForChild("PlayerGui")
if pg:FindFirstChild("RichieHubUI") then pg.RichieHubUI:Destroy() end

local SG=Instance.new("ScreenGui")
SG.Name="RichieHubUI"
SG.ResetOnSpawn=false
SG.IgnoreGuiInset=true
SG.ZIndexBehavior=Enum.ZIndexBehavior.Sibling
SG.Parent=pg

-- ============ NOTIFICATION SYSTEM ============
local notifHolder = Instance.new("Frame")
notifHolder.Size = UDim2.new(0, 250, 0, 300)
notifHolder.Position = UDim2.new(0, 20, 0, 100)
notifHolder.BackgroundTransparency = 1
notifHolder.Parent = SG
local notifList = Instance.new("UIListLayout", notifHolder)
notifList.Padding = UDim.new(0, 6)
notifList.SortOrder = Enum.SortOrder.LayoutOrder
notifList.VerticalAlignment = Enum.VerticalAlignment.Top

local function notifyColor(text, color)
    task.spawn(function()
        local box = Instance.new("Frame")
        box.Size = UDim2.new(1, 0, 0, 36)
        box.BackgroundColor3 = Color3.fromRGB(20, 20, 24)
        box.BackgroundTransparency = 0.1
        box.BorderSizePixel = 0
        box.Parent = notifHolder
        Instance.new("UICorner", box).CornerRadius = UDim.new(0, 8)
        local stroke = Instance.new("UIStroke", box)
        stroke.Thickness = 2
        stroke.Color = color
        stroke.Transparency = 0.2
        local lbl = Instance.new("TextLabel")
        lbl.Size = UDim2.new(1, -16, 1, 0)
        lbl.Position = UDim2.new(0, 8, 0, 0)
        lbl.BackgroundTransparency = 1
        lbl.Text = text
        lbl.TextColor3 = color
        lbl.Font = Enum.Font.GothamSemibold
        lbl.TextSize = 13
        lbl.TextXAlignment = Enum.TextXAlignment.Left
        lbl.Parent = box
        box.BackgroundTransparency = 1
        stroke.Transparency = 1
        lbl.TextTransparency = 1
        T:Create(box, TweenInfo.new(0.2), {BackgroundTransparency = 0.1}):Play()
        T:Create(stroke, TweenInfo.new(0.2), {Transparency = 0.2}):Play()
        T:Create(lbl, TweenInfo.new(0.2), {TextTransparency = 0}):Play()
        task.wait(2)
        T:Create(box, TweenInfo.new(0.4), {BackgroundTransparency = 1}):Play()
        T:Create(stroke, TweenInfo.new(0.4), {Transparency = 1}):Play()
        T:Create(lbl, TweenInfo.new(0.4), {TextTransparency = 1}):Play()
        task.wait(0.4)
        box:Destroy()
    end)
end

local function notifyGreen(text) notifyColor(text, Color3.fromRGB(80, 255, 80)) end
local function notifyRed(text) notifyColor(text, Color3.fromRGB(255, 80, 80)) end

local function notify(text)
    task.spawn(function()
        local box = Instance.new("Frame")
        box.Size = UDim2.new(1, 0, 0, 36)
        box.BackgroundColor3 = Color3.fromRGB(20, 20, 24)
        box.BackgroundTransparency = 0.1
        box.BorderSizePixel = 0
        box.Parent = notifHolder
        Instance.new("UICorner", box).CornerRadius = UDim.new(0, 8)
        local stroke = Instance.new("UIStroke", box)
        stroke.Thickness = 2
        stroke.Color = Color3.fromRGB(80, 200, 120)
        stroke.Transparency = 0.2
        local lbl = Instance.new("TextLabel")
        lbl.Size = UDim2.new(1, -16, 1, 0)
        lbl.Position = UDim2.new(0, 8, 0, 0)
        lbl.BackgroundTransparency = 1
        lbl.Text = text
        lbl.TextColor3 = Color3.fromRGB(220, 220, 220)
        lbl.Font = Enum.Font.GothamSemibold
        lbl.TextSize = 13
        lbl.TextXAlignment = Enum.TextXAlignment.Left
        lbl.Parent = box
        box.BackgroundTransparency = 1
        stroke.Transparency = 1
        lbl.TextTransparency = 1
        T:Create(box, TweenInfo.new(0.2), {BackgroundTransparency = 0.1}):Play()
        T:Create(stroke, TweenInfo.new(0.2), {Transparency = 0.2}):Play()
        T:Create(lbl, TweenInfo.new(0.2), {TextTransparency = 0}):Play()
        task.wait(2)
        T:Create(box, TweenInfo.new(0.4), {BackgroundTransparency = 1}):Play()
        T:Create(stroke, TweenInfo.new(0.4), {Transparency = 1}):Play()
        T:Create(lbl, TweenInfo.new(0.4), {TextTransparency = 1}):Play()
        task.wait(0.4)
        box:Destroy()
    end)
end

local M=Instance.new("Frame")
M.Size=UDim2.new(0,420,0,320)
M.Position=UDim2.new(0.5,-210,0.5,-160)
M.BackgroundColor3=Color3.fromRGB(15,15,18)
M.BackgroundTransparency=0.25
M.BorderSizePixel=0
M.Active=true
M.Draggable=true
M.Parent=SG
Instance.new("UICorner",M).CornerRadius=UDim.new(0,12)

local Edge=Instance.new("UIStroke",M)
Edge.Thickness=2
Edge.Transparency=0

task.spawn(function()
    local t=0
    while Edge.Parent do
        t=t+0.03
        local r=math.floor(math.sin(t)*127+128)
        local g=math.floor(math.sin(t+2)*127+128)
        local b=math.floor(math.sin(t+4)*127+128)
        Edge.Color=Color3.fromRGB(r,g,b)
        task.wait(0.02)
    end
end)

local TitleBar=Instance.new("Frame")
TitleBar.Size=UDim2.new(1,0,0,38)
TitleBar.BackgroundColor3=Color3.fromRGB(20,20,24)
TitleBar.BackgroundTransparency=0.3
TitleBar.BorderSizePixel=0
TitleBar.Parent=M
Instance.new("UICorner",TitleBar).CornerRadius=UDim.new(0,12)

local TitleBarFix=Instance.new("Frame")
TitleBarFix.Size=UDim2.new(1,0,0,12)
TitleBarFix.Position=UDim2.new(0,0,1,-12)
TitleBarFix.BackgroundColor3=Color3.fromRGB(20,20,24)
TitleBarFix.BackgroundTransparency=0.3
TitleBarFix.BorderSizePixel=0
TitleBarFix.Parent=TitleBar

local TitleText=Instance.new("TextLabel")
TitleText.Size=UDim2.new(1,-100,1,0)
TitleText.Position=UDim2.new(0,45,0,0)
TitleText.BackgroundTransparency=1
TitleText.Text="Richice Hub"
TitleText.TextColor3=Color3.fromRGB(255,255,255)
TitleText.Font=Enum.Font.GothamBlack
TitleText.TextSize=18
TitleText.TextXAlignment=Enum.TextXAlignment.Left
TitleText.Parent=TitleBar



-- ============ WATERMARK (next to title) ============
local watermarkText = Instance.new("TextLabel")
watermarkText.Size = UDim2.new(0, 150, 0, 12)
watermarkText.Position = UDim2.new(0, 195, 0.5, -6)
watermarkText.BackgroundTransparency = 1
watermarkText.Text = "Made By Richice"
watermarkText.TextColor3 = Color3.fromRGB(0, 160, 255)
watermarkText.Font = Enum.Font.GothamBold
watermarkText.TextSize = 12
watermarkText.TextXAlignment = Enum.TextXAlignment.Left
watermarkText.Parent = TitleBar
watermarkText.ZIndex = 0

local watermarkStroke = Instance.new("UIStroke", watermarkText)
watermarkStroke.Thickness = 1
watermarkStroke.Color = Color3.fromRGB(80, 200, 120)
watermarkStroke.Transparency = 0.3

task.spawn(function()
    local t=0
    while TitleText.Parent do
        t=t+0.03
        local r=math.floor(math.sin(t)*127+128)
        local g=math.floor(math.sin(t+2)*127+128)
        local b=math.floor(math.sin(t+4)*127+128)
        TitleText.TextColor3=Color3.fromRGB(r,g,b)
        task.wait(0.02)
    end
end)

local Mn=Instance.new("TextButton")
Mn.Size=UDim2.new(0,26,0,26)
Mn.Position=UDim2.new(0,8,0,6)
Mn.BackgroundColor3=Color3.fromRGB(35,35,40)
Mn.BackgroundTransparency=0.3
Mn.Text="≡"
Mn.TextColor3=Color3.fromRGB(200,200,200)
Mn.Font=Enum.Font.GothamBold
Mn.TextSize=16
Mn.BorderSizePixel=0
Mn.AutoButtonColor=false
Mn.Parent=TitleBar
Instance.new("UICorner",Mn).CornerRadius=UDim.new(0,6)

local Cl=Instance.new("TextButton")
Cl.Size=UDim2.new(0,30,0,30)
Cl.Position=UDim2.new(1,-34,0,6)
Cl.BackgroundColor3=Color3.fromRGB(180,45,45)
Cl.BackgroundTransparency=0.2
Cl.Text="X"
Cl.TextColor3=Color3.fromRGB(255,255,255)
Cl.Font=Enum.Font.GothamBold
Cl.TextSize=13
Cl.BorderSizePixel=0
Cl.AutoButtonColor=false
Cl.Parent=TitleBar
Instance.new("UICorner",Cl).CornerRadius=UDim.new(0,6)

local RestoreBtn=Instance.new("TextButton")
RestoreBtn.Size=UDim2.new(0,40,0,40)
RestoreBtn.Position=UDim2.new(0,10,0,60)
RestoreBtn.BackgroundColor3=Color3.fromRGB(15,15,18)
RestoreBtn.BackgroundTransparency=0.25
RestoreBtn.Text="R"
RestoreBtn.TextColor3=Color3.fromRGB(255,255,255)
RestoreBtn.Font=Enum.Font.GothamBold
RestoreBtn.TextSize=16
RestoreBtn.BorderSizePixel=0
RestoreBtn.AutoButtonColor=false
RestoreBtn.Visible=false
RestoreBtn.Parent=SG
Instance.new("UICorner",RestoreBtn).CornerRadius=UDim.new(1,0)

Mn.MouseButton1Click:Connect(function() M.Visible=false RestoreBtn.Visible=true end)
RestoreBtn.MouseButton1Click:Connect(function() M.Visible=true RestoreBtn.Visible=false end)

local Sidebar=Instance.new("ScrollingFrame")
Sidebar.Size=UDim2.new(0,130,1,-50)
Sidebar.Position=UDim2.new(0,8,0,44)
Sidebar.BackgroundTransparency=1
Sidebar.BorderSizePixel=0
Sidebar.ScrollBarThickness=3
Sidebar.ScrollBarImageColor3=Color3.fromRGB(80,80,90)
Sidebar.CanvasSize=UDim2.new(0,0,0,0)
Sidebar.Parent=M
local sidebarList=Instance.new("UIListLayout",Sidebar)
sidebarList.Padding=UDim.new(0,6)
sidebarList.SortOrder=Enum.SortOrder.LayoutOrder
sidebarList:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
    Sidebar.CanvasSize=UDim2.new(0,0,0,sidebarList.AbsoluteContentSize.Y+20)
end)

local function mkTab(name, emoji, order)
    local b=Instance.new("TextButton")
    b.Size=UDim2.new(1,0,0,32)
    b.BackgroundColor3=Color3.fromRGB(20,20,24)
    b.BackgroundTransparency=0.35
    b.Text="  "..emoji.."  "..name
    b.TextColor3=Color3.fromRGB(200,200,200)
    b.Font=Enum.Font.GothamSemibold
    b.TextSize=12
    b.TextXAlignment=Enum.TextXAlignment.Left
    b.BorderSizePixel=0
    b.AutoButtonColor=false
    b.LayoutOrder=order
    b.Parent=Sidebar
    Instance.new("UICorner",b).CornerRadius=UDim.new(0,8)
    local acc=Instance.new("Frame")
    acc.Size=UDim2.new(0,3,1,0)
    acc.BackgroundColor3=Color3.fromRGB(80,200,120)
    acc.BorderSizePixel=0
    acc.Visible=false
    acc.Parent=b
    Instance.new("UICorner",acc).CornerRadius=UDim.new(1,0)
    return b
end

local TargetTab=mkTab("Target","🎯",1)
local MainTab=mkTab("Main","🧠",2)
local CombatTab=mkTab("Combat","⚔️",3)
local VisualsTab=mkTab("Visuals","👁️",4)
local WorldTab=mkTab("World","🌍",5)
local ConfigTab=mkTab("Config","💾",6)
local KeybindTab=mkTab("Keybinds","⌨️",7)

local function setActiveTab(active)
    for _,tab in pairs({TargetTab,MainTab,CombatTab,VisualsTab,WorldTab,ConfigTab,KeybindTab}) do
        T:Create(tab,TweenInfo.new(0.2),{
            BackgroundColor3=(tab==active) and Color3.fromRGB(40,40,48) or Color3.fromRGB(20,20,24),
            TextColor3=(tab==active) and Color3.fromRGB(255,255,255) or Color3.fromRGB(200,200,200)
        }):Play()
        local acc=tab:FindFirstChildOfClass("Frame")
        if acc then acc.Visible=(tab==active) end
    end
end

local Content=Instance.new("Frame")
Content.Size=UDim2.new(1,-146,1,-50)
Content.Position=UDim2.new(0,138,0,44)
Content.BackgroundTransparency=1
Content.Parent=M

local function mkPage(name)
    local s=Instance.new("ScrollingFrame")
    s.Name=name
    s.Size=UDim2.new(1,0,1,0)
    s.BackgroundTransparency=1
    s.BorderSizePixel=0
    s.ScrollBarThickness=3
    s.ScrollBarImageColor3=Color3.fromRGB(80,80,90)
    s.CanvasSize=UDim2.new(0,0,0,0)
    s.Visible=false
    s.Parent=Content
    local l=Instance.new("UIListLayout",s)
    l.Padding=UDim.new(0,6)
    l.SortOrder=Enum.SortOrder.LayoutOrder
    l:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
        s.CanvasSize=UDim2.new(0,0,0,l.AbsoluteContentSize.Y+20)
    end)
    return s
end

local TargetPage=mkPage("TargetPage")
local MainPage=mkPage("MainPage")
local CombatPage=mkPage("CombatPage")
local VisualsPage=mkPage("VisualsPage")
local WorldPage=mkPage("WorldPage")
local ConfigPage=mkPage("ConfigPage")
local KeybindPage=mkPage("KeybindPage")

local function showPage(p)
    for _,page in pairs({TargetPage,MainPage,CombatPage,VisualsPage,WorldPage,ConfigPage,KeybindPage}) do
        page.Visible=(page==p)
    end
end

TargetTab.MouseButton1Click:Connect(function() setActiveTab(TargetTab) showPage(TargetPage) end)
MainTab.MouseButton1Click:Connect(function() setActiveTab(MainTab) showPage(MainPage) end)
CombatTab.MouseButton1Click:Connect(function() setActiveTab(CombatTab) showPage(CombatPage) end)
VisualsTab.MouseButton1Click:Connect(function() setActiveTab(VisualsTab) showPage(VisualsPage) end)
WorldTab.MouseButton1Click:Connect(function() setActiveTab(WorldTab) showPage(WorldPage) end)
ConfigTab.MouseButton1Click:Connect(function() setActiveTab(ConfigTab) showPage(ConfigPage) end)
KeybindTab.MouseButton1Click:Connect(function() setActiveTab(KeybindTab) showPage(KeybindPage) end)

setActiveTab(MainTab)
showPage(MainPage)

local function mkLabel(p,t)
    local l=Instance.new("TextLabel")
    l.Size=UDim2.new(1,-6,0,22)
    l.BackgroundTransparency=1
    l.Text="  "..t
    l.TextColor3=Color3.fromRGB(140,140,150)
    l.Font=Enum.Font.GothamBold
    l.TextSize=11
    l.TextXAlignment=Enum.TextXAlignment.Left
    l.Parent=p
    return l
end

local keybindTargets = {}
local keybindButtons = {}
_G.richieToggleState = {}

local function mkTog(p,t,cb)
    local h=Instance.new("Frame")
    h.Size=UDim2.new(1,-6,0,40)
    h.BackgroundColor3=Color3.fromRGB(30,30,36)
    h.BackgroundTransparency=0.3
    h.BorderSizePixel=0
    h.Parent=p
    Instance.new("UICorner",h).CornerRadius=UDim.new(0,8)
    local l=Instance.new("TextLabel")
    l.Size=UDim2.new(1,-56,1,0)
    l.Position=UDim2.new(0,14,0,0)
    l.BackgroundTransparency=1
    l.Text=t
    l.TextColor3=Color3.fromRGB(220,220,220)
    l.Font=Enum.Font.GothamMedium
    l.TextSize=13
    l.TextXAlignment=Enum.TextXAlignment.Left
    l.Parent=h
    local kb=Instance.new("Frame")
    kb.Size=UDim2.new(0,36,0,18)
    kb.Position=UDim2.new(1,-48,0.5,-9)
    kb.BackgroundColor3=Color3.fromRGB(60,60,66)
    kb.BorderSizePixel=0
    kb.Parent=h
    Instance.new("UICorner",kb).CornerRadius=UDim.new(1,0)
    local k=Instance.new("Frame")
    k.Size=UDim2.new(0,14,0,14)
    k.Position=UDim2.new(0,2,0.5,-7)
    k.BackgroundColor3=Color3.fromRGB(200,200,200)
    k.BorderSizePixel=0
    k.Parent=kb
    Instance.new("UICorner",k).CornerRadius=UDim.new(1,0)
    local on=false
    local b=Instance.new("TextButton")
    b.Size=UDim2.new(1,0,1,0)
    b.BackgroundTransparency=1
    b.Text=""
    b.Parent=h
    local function setState(newState)
        on=newState
        T:Create(kb,TweenInfo.new(0.25,Enum.EasingStyle.Quart),{BackgroundColor3=on and Color3.fromRGB(80,200,120) or Color3.fromRGB(60,60,66)}):Play()
        T:Create(k,TweenInfo.new(0.25,Enum.EasingStyle.Quart),{Position=on and UDim2.new(1,-16,0.5,-7) or UDim2.new(0,2,0.5,-7)}):Play()
    end
    b.MouseButton1Click:Connect(function()
        setState(not on)
        if _G.richieToggleState then
            _G.richieToggleState[t] = on
        end
        if cb then cb(on) end
    end)
    local handle = {setState=setState, onChange=cb}
    keybindTargets[t] = handle
    return handle
end

local function mkBtn(p,t,cb)
    local b=Instance.new("TextButton")
    b.Size=UDim2.new(1,-6,0,36)
    b.BackgroundColor3=Color3.fromRGB(30,30,36)
    b.BackgroundTransparency=0.2
    b.Text=t
    b.TextColor3=Color3.fromRGB(220,220,220)
    b.Font=Enum.Font.GothamSemibold
    b.TextSize=13
    b.BorderSizePixel=0
    b.AutoButtonColor=false
    b.Parent=p
    Instance.new("UICorner",b).CornerRadius=UDim.new(0,8)
    b.MouseButton1Click:Connect(function()
        T:Create(b,TweenInfo.new(0.1),{BackgroundColor3=Color3.fromRGB(80,200,120)}):Play()
        task.wait(0.15)
        T:Create(b,TweenInfo.new(0.15),{BackgroundColor3=Color3.fromRGB(30,30,36)}):Play()
        if cb then cb() end
    end)
    keybindButtons[t] = {fire=cb}
    return b
end

local function mkInp(p,ph)
    local b=Instance.new("TextBox")
    b.Size=UDim2.new(1,-6,0,34)
    b.BackgroundColor3=Color3.fromRGB(25,25,30)
    b.BackgroundTransparency=0.2
    b.PlaceholderText=ph
    b.Text=""
    b.TextColor3=Color3.fromRGB(220,220,220)
    b.PlaceholderColor3=Color3.fromRGB(120,120,130)
    b.Font=Enum.Font.Gotham
    b.TextSize=13
    b.BorderSizePixel=0
    b.ClearTextOnFocus=false
    b.Parent=p
    Instance.new("UICorner",b).CornerRadius=UDim.new(0,8)
    b.Focused:Connect(function()
        if b.Text=="Not found!" or b.Text=="Name required!" or b.Text:sub(1,7)=="Saved: " then
            b.Text=""
        end
    end)
    return b
end

local savedValues={}
local function mkNum(p,t,key,default,cb)
    savedValues[key]=default
    local h=Instance.new("Frame")
    h.Size=UDim2.new(1,-6,0,58)
    h.BackgroundColor3=Color3.fromRGB(30,30,36)
    h.BackgroundTransparency=0.3
    h.BorderSizePixel=0
    h.Parent=p
    Instance.new("UICorner",h).CornerRadius=UDim.new(0,8)
    local l=Instance.new("TextLabel")
    l.Size=UDim2.new(1,-16,0,20)
    l.Position=UDim2.new(0,14,0,6)
    l.BackgroundTransparency=1
    l.Text=t
    l.TextColor3=Color3.fromRGB(200,200,200)
    l.Font=Enum.Font.GothamSemibold
    l.TextSize=12
    l.TextXAlignment=Enum.TextXAlignment.Left
    l.Parent=h
    local box=Instance.new("TextBox")
    box.Size=UDim2.new(1,-28,0,26)
    box.Position=UDim2.new(0,14,0,28)
    box.BackgroundColor3=Color3.fromRGB(20,20,24)
    box.BackgroundTransparency=0.2
    box.Text=tostring(default)
    box.TextColor3=Color3.fromRGB(220,220,220)
    box.Font=Enum.Font.GothamBold
    box.TextSize=13
    box.BorderSizePixel=0
    box.ClearTextOnFocus=false
    box.Parent=h
    Instance.new("UICorner",box).CornerRadius=UDim.new(0,6)
    box.FocusLost:Connect(function()
        local num=tonumber(box.Text)
        if num then
            savedValues[key]=num
            cb(num)
        else
            box.Text=tostring(savedValues[key])
            cb(savedValues[key])
        end
    end)
    return h, box
end

local function getCh() return LP.Character or LP.CharacterAdded:Wait() end

local origAmb=L.Ambient
local origOutdoor=L.OutdoorAmbient
local origFogStart=L.FogStart
local origFogEnd=L.FogEnd
local origBright=L.Brightness
local origGrav=W.Gravity

local fly=false
local flySpd=50
local flyC,flyBV,flyBG
local flyAnimTrack

local function stopFly()
    fly=false
    if flyAnimTrack then pcall(function() flyAnimTrack:Stop() end) flyAnimTrack=nil end
    if flyC then flyC:Disconnect() flyC=nil end
    local ch=LP.Character
    if ch then
        local hrp=ch:FindFirstChild("HumanoidRootPart")
        if hrp then hrp.Anchored=false end
        local hm=ch:FindFirstChild("Humanoid")
        if hm then hm.PlatformStand=false end
    end
end

local function startFly()
    local ch = getCh()
    local hrp = ch:WaitForChild("HumanoidRootPart")
    local hm = ch:WaitForChild("Humanoid")
    hm.PlatformStand = true
    hrp.Anchored = true
    local animator = hm:FindFirstChildOfClass("Animator")
    if animator then
        local anim = Instance.new("Animation")
        anim.AnimationId = "rbxassetid://507766666"
        local track = animator:LoadAnimation(anim)
        track.Priority = Enum.AnimationPriority.Action
        track.Looped = true
        track:Play()
        flyAnimTrack = track
    end
    local plr = game:GetService("Players").LocalPlayer
    local plrControls
    local ok2, res = pcall(function() return require(plr.PlayerScripts.PlayerModule.ControlModule) end)
    if ok2 then plrControls = res end
    flyC = R.RenderStepped:Connect(function()
        if not fly then return end
        if not plrControls then return end
        local h2 = ch:FindFirstChild("HumanoidRootPart")
        if not h2 then return end
        local moveDir = plrControls:GetMoveVector()
        local camCF = C.CFrame
        local newPos = h2.Position
        if moveDir.Magnitude > 0 then
            local camRotation = camCF - camCF.Position
            local direction = camRotation * moveDir
            newPos = newPos + direction.Unit * (flySpd * 0.05)
        end
        h2.CFrame = CFrame.new(newPos, newPos + camCF.LookVector)
    end)
end

-- ============ MAIN ============
do
mkLabel(MainPage,"MOVEMENT")
mkTog(MainPage,"Fly",function(on) fly=on if on then startFly() else stopFly() end end)
mkNum(MainPage,"Fly Speed","flySpd",50,function(v) flySpd=v end)
mkNum(MainPage,"Speed","speed",16,function(v)
    local ch=LP.Character
    if ch and ch:FindFirstChild("Humanoid") then ch.Humanoid.WalkSpeed=v end
end)

local speedPresets = Instance.new("Frame")
speedPresets.Size = UDim2.new(1,-6,0,34)
speedPresets.BackgroundTransparency = 1
speedPresets.Parent = MainPage
local spLayout = Instance.new("UIListLayout", speedPresets)
spLayout.FillDirection = Enum.FillDirection.Horizontal
spLayout.Padding = UDim.new(0,4)
spLayout.SortOrder = Enum.SortOrder.LayoutOrder

local function setWalk(v)
    local ch=LP.Character
    if ch and ch:FindFirstChild("Humanoid") then
        ch.Humanoid.WalkSpeed=v
        savedValues["speed"]=v
        notify("Speed: "..v)
    end
end

for _,preset in ipairs({{"Slow",8},{"Normal",16},{"Fast",32},{"Blaze",100}}) do
    local b=Instance.new("TextButton")
    b.Size=UDim2.new(0.25,-3,1,0)
    b.BackgroundColor3=Color3.fromRGB(30,30,36)
    b.BackgroundTransparency=0.2
    b.Text=preset[1]
    b.TextColor3=Color3.fromRGB(220,220,220)
    b.Font=Enum.Font.GothamBold
    b.TextSize=12
    b.BorderSizePixel=0
    b.AutoButtonColor=false
    b.Parent=speedPresets
    Instance.new("UICorner",b).CornerRadius=UDim.new(0,6)
    b.MouseButton1Click:Connect(function()
        T:Create(b,TweenInfo.new(0.1),{BackgroundColor3=Color3.fromRGB(80,200,120)}):Play()
        task.wait(0.15)
        T:Create(b,TweenInfo.new(0.15),{BackgroundColor3=Color3.fromRGB(30,30,36)}):Play()
        setWalk(preset[2])
    end)
end

mkNum(MainPage,"Jump Power","jump",50,function(v)
    local ch=LP.Character
    if ch and ch:FindFirstChild("Humanoid") then
        ch.Humanoid.UseJumpPower=true
        ch.Humanoid.JumpPower=v
    end
end)

local sprintC
mkTog(MainPage,"Auto-Sprint",function(on)
    if sprintC then sprintC:Disconnect() sprintC=nil end
    if on then
        local vu=game:GetService("VirtualUser")
        local lastTouch={}
        sprintC=R.Heartbeat:Connect(function()
            local ch=LP.Character
            if not ch then return end
            local hm=ch:FindFirstChildOfClass("Humanoid")
            if not hm or hm.MoveDirection.Magnitude < 0.1 then return end
            pcall(function() vu:KeyPress(Enum.KeyCode.LeftShift) end)
            pcall(function() vu:KeyPress(Enum.KeyCode.LeftControl) end)
            pcall(function()
                local pg = LP:FindFirstChild("PlayerGui")
                if not pg then return end
                for _, gui in pairs(pg:GetDescendants()) do
                    if gui:IsA("ImageButton") or gui:IsA("TextButton") then
                        local n = gui.Name:lower()
                        if n:find("sprint") or n:find("run") or n:find("shift") or n:find("dash") then
                            if gui.Visible then
                                local now=tick()
                                if not lastTouch[gui] or now-lastTouch[gui] > 0.15 then
                                    lastTouch[gui]=now
                                    local pos = gui.AbsolutePosition + gui.AbsoluteSize/2
                                    vu:Button1Down(Vector2.new(pos.X,pos.Y), C.CFrame)
                                    task.defer(function()
                                        task.wait(0.05)
                                        vu:Button1Up(Vector2.new(pos.X,pos.Y), C.CFrame)
                                    end)
                                end
                            end
                        end
                    end
                end
            end)
        end)
    end
end)

local ajC
local ajDebounce=false
mkTog(MainPage,"Auto-Jump",function(on)
    if on then
        ajC=R.Heartbeat:Connect(function()
            if ajDebounce then return end
            local ch=LP.Character
            if not ch then return end
            local hm=ch:FindFirstChild("Humanoid")
            local hrp=ch:FindFirstChild("HumanoidRootPart")
            if not hm or not hrp then return end
            local state=hm:GetState()
            if state==Enum.HumanoidStateType.Running or state==Enum.HumanoidStateType.RunningNoPhysics then
                local params=RaycastParams.new()
                params.FilterType=Enum.RaycastFilterType.Exclude
                params.FilterDescendantsInstances={ch}
                local moveDir=hm.MoveDirection
                if moveDir.Magnitude>0 then
                    local ray=W:Raycast(hrp.Position, moveDir*3, params)
                    if ray then
                        ajDebounce=true
                        hm:ChangeState(Enum.HumanoidStateType.Jumping)
                        task.wait(0.4)
                        ajDebounce=false
                    end
                end
            end
        end)
    else
        if ajC then ajC:Disconnect() ajC=nil end
        ajDebounce=false
    end
end)

mkLabel(MainPage,"CAMERA")

mkNum(MainPage,"FOV","fov",70,function(v) C.FieldOfView=v end)

local shiftLockOn=false
local shiftLockC
local ShiftCircle=Instance.new("Frame")
ShiftCircle.Size=UDim2.new(0,40,0,40)
ShiftCircle.Position=UDim2.new(1,-60,1,-180)
ShiftCircle.BackgroundColor3=Color3.fromRGB(0,0,0)
ShiftCircle.BackgroundTransparency=0.35
ShiftCircle.BorderSizePixel=0
ShiftCircle.Visible=false
ShiftCircle.ZIndex=300
ShiftCircle.Parent=SG
Instance.new("UICorner",ShiftCircle).CornerRadius=UDim.new(1,0)

local ShiftIcon=Instance.new("TextLabel", ShiftCircle)
ShiftIcon.Size=UDim2.new(1,0,1,0)
ShiftIcon.BackgroundTransparency=1
ShiftIcon.Text="🔒"
ShiftIcon.TextColor3=Color3.fromRGB(255,255,255)
ShiftIcon.TextSize=20
ShiftIcon.Font=Enum.Font.GothamBold
ShiftIcon.ZIndex=302

local ShiftClick=Instance.new("TextButton", ShiftCircle)
ShiftClick.Size=UDim2.new(1,0,1,0)
ShiftClick.BackgroundTransparency=1
ShiftClick.Text=""
ShiftClick.ZIndex=303
ShiftClick.MouseButton1Click:Connect(function()
    if keybindTargets["Shift Lock (Mobile)"] then
        local cur=_G.richieToggleState and _G.richieToggleState["Shift Lock (Mobile)"]
        if cur==nil then cur=false end
        local newState=not cur
        _G.richieToggleState["Shift Lock (Mobile)"]=newState
        keybindTargets["Shift Lock (Mobile)"].setState(newState)
        if keybindTargets["Shift Lock (Mobile)"].onChange then
            keybindTargets["Shift Lock (Mobile)"].onChange(newState)
        end
    end
end)

local PCLock = Instance.new("Frame")
PCLock.Size = UDim2.new(0, 16, 0, 16)
PCLock.Position = UDim2.new(0.5, -8, 0.5, -8)
PCLock.BackgroundColor3 = Color3.fromRGB(0,0,0)
PCLock.BackgroundTransparency = 0.3
PCLock.BorderSizePixel = 0
PCLock.ZIndex = 200
PCLock.Visible = false
PCLock.Parent = SG
Instance.new("UICorner", PCLock).CornerRadius = UDim.new(1, 0)

local PCLockDot = Instance.new("Frame", PCLock)
PCLockDot.Size = UDim2.new(0, 5, 0, 5)
PCLockDot.Position = UDim2.new(0.5, -2.5, 0.5, -2.5)
PCLockDot.BackgroundColor3 = Color3.fromRGB(255,255,255)
PCLockDot.BorderSizePixel = 0
PCLockDot.ZIndex = 201
Instance.new("UICorner", PCLockDot).CornerRadius = UDim.new(1, 0)


mkTog(MainPage,"Shift Lock (Mobile)",function(on)
    shiftLockOn=on
    ShiftCircle.Visible=on
    PCLock.Visible=on
    if on then
        shiftLockC=R.RenderStepped:Connect(function()
            if not shiftLockOn then return end
            local ch=LP.Character
            if ch and ch:FindFirstChild("Humanoid") and ch:FindFirstChild("HumanoidRootPart") then
                local camLook = C.CFrame.LookVector
                local flatLook = Vector3.new(camLook.X, 0, camLook.Z)
                if flatLook.Magnitude > 0 then
                    ch.HumanoidRootPart.CFrame = CFrame.new(ch.HumanoidRootPart.Position, ch.HumanoidRootPart.Position + flatLook.Unit)
                end
            end
        end)
    else
        if shiftLockC then shiftLockC:Disconnect() shiftLockC=nil end
    end
end)

mkTog(MainPage,"Infinite Zoom",function(on)
    if on then
        LP.CameraMaxZoomDistance = math.huge
        LP.CameraMinZoomDistance = 0.5
    else
        LP.CameraMaxZoomDistance = 128
        LP.CameraMinZoomDistance = 0.5
    end
end)

mkLabel(MainPage,"PLAYER")
mkTog(MainPage,"Infinite Jump",function(on)
    if on then
        _G.richieIJ=U.JumpRequest:Connect(function()
            local ch=LP.Character
            if ch and ch:FindFirstChild("Humanoid") then
                ch.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
            end
        end)
    else
        if _G.richieIJ then _G.richieIJ:Disconnect() _G.richieIJ=nil end
    end
end)

mkTog(MainPage,"Noclip",function(on)
    if on then
        _G.richieNoclip=R.Stepped:Connect(function()
            local ch=LP.Character
            if ch then
                for _,p in pairs(ch:GetDescendants()) do
                    if p:IsA("BasePart") and p.CanCollide then p.CanCollide=false end
                end
            end
        end)
    else
        if _G.richieNoclip then _G.richieNoclip:Disconnect() _G.richieNoclip=nil end
        local ch=LP.Character
        if ch then
            for _,p in pairs(ch:GetDescendants()) do
                if p:IsA("BasePart") then p.CanCollide=true end
            end
        end
    end
end)

mkTog(MainPage,"Anti-Sit",function(on)
    if on then
        _G.richieAntiSit=LP.CharacterAdded:Connect(function(ch)
            task.wait(0.5)
            local hm=ch:WaitForChild("Humanoid",5)
            if hm then hm.Sit=false end
        end)
        if LP.Character then
            local hm=LP.Character:FindFirstChild("Humanoid")
            if hm then
                _G.richieAntiSitBlock=R.Heartbeat:Connect(function()
                    if hm.Sit then hm.Sit=false end
                end)
            end
        end
    else
        if _G.richieAntiSit then _G.richieAntiSit:Disconnect() _G.richieAntiSit=nil end
        if _G.richieAntiSitBlock then _G.richieAntiSitBlock:Disconnect() _G.richieAntiSitBlock=nil end
    end
end)

mkLabel(MainPage,"POSITIONS")
local posNameInput=mkInp(MainPage,"Enter position name...")
local savedPositions = {}
local posListFrame = Instance.new("Frame")
posListFrame.Size=UDim2.new(1,-6,0,0)
posListFrame.BackgroundColor3=Color3.fromRGB(30,30,36)
posListFrame.BackgroundTransparency=0.3
posListFrame.BorderSizePixel=0
posListFrame.Visible=false
posListFrame.Parent=MainPage
Instance.new("UICorner",posListFrame).CornerRadius=UDim.new(0,8)
local posList = Instance.new("UIListLayout",posListFrame)
posList.Padding=UDim.new(0,4)
posList.SortOrder=Enum.SortOrder.LayoutOrder

local function refreshPosList()
    for _,c in pairs(posListFrame:GetChildren()) do
        if c:IsA("TextButton") or c:IsA("Frame") then c:Destroy() end
    end
    if #savedPositions == 0 then
        posListFrame.Visible=false
        posListFrame.Size=UDim2.new(1,-6,0,0)
        return
    end
    posListFrame.Visible=true
    for i,entry in pairs(savedPositions) do
        local row=Instance.new("Frame")
        row.Size=UDim2.new(1,0,0,34)
        row.BackgroundTransparency=1
        row.LayoutOrder=i
        row.Parent=posListFrame
        local nameLbl=Instance.new("TextLabel")
        nameLbl.Size=UDim2.new(0.4,0,1,0)
        nameLbl.Position=UDim2.new(0,4,0,0)
        nameLbl.BackgroundTransparency=1
        nameLbl.Text=entry.name
        nameLbl.TextColor3=Color3.fromRGB(200,200,200)
        nameLbl.Font=Enum.Font.GothamBold
        nameLbl.TextSize=12
        nameLbl.TextXAlignment=Enum.TextXAlignment.Left
        nameLbl.TextTruncate=Enum.TextTruncate.AtEnd
        nameLbl.Parent=row
        local tpBtn=Instance.new("TextButton")
        tpBtn.Size=UDim2.new(0.28,0,1,0)
        tpBtn.Position=UDim2.new(0.42,0,0,0)
        tpBtn.BackgroundColor3=Color3.fromRGB(80,200,120)
        tpBtn.Text="TP"
        tpBtn.TextColor3=Color3.fromRGB(255,255,255)
        tpBtn.Font=Enum.Font.GothamBold
        tpBtn.TextSize=11
        tpBtn.BorderSizePixel=0
        tpBtn.Parent=row
        Instance.new("UICorner",tpBtn).CornerRadius=UDim.new(0,6)
        tpBtn.MouseButton1Click:Connect(function()
            local ch=LP.Character
            if ch and ch:FindFirstChild("HumanoidRootPart") then
                ch.HumanoidRootPart.CFrame=entry.pos
            end
        end)
        local delBtn=Instance.new("TextButton")
        delBtn.Size=UDim2.new(0.28,0,1,0)
        delBtn.Position=UDim2.new(0.72,0,0,0)
        delBtn.BackgroundColor3=Color3.fromRGB(180,45,45)
        delBtn.Text="Delete"
        delBtn.TextColor3=Color3.fromRGB(255,255,255)
        delBtn.Font=Enum.Font.GothamBold
        delBtn.TextSize=11
        delBtn.BorderSizePixel=0
        delBtn.Parent=row
        Instance.new("UICorner",delBtn).CornerRadius=UDim.new(0,6)
        delBtn.MouseButton1Click:Connect(function()
            table.remove(savedPositions, i)
            refreshPosList()
        end)
    end
    posListFrame.Size=UDim2.new(1,-6,0, 8 + #savedPositions * 38)
end

mkBtn(MainPage,"Save Position",function()
    local name=posNameInput.Text
    if not name or name=="" then
        posNameInput.Text="Name required!"
        return
    end
    local ch=LP.Character
    if ch and ch:FindFirstChild("HumanoidRootPart") then
        table.insert(savedPositions, {name=name, pos=ch.HumanoidRootPart.CFrame})
        posNameInput.Text=""
        refreshPosList()
    end
end)

mkBtn(MainPage,"Show Positions",function()
    posListFrame.Visible = not posListFrame.Visible
    if posListFrame.Visible then refreshPosList() end
end)

mkLabel(MainPage,"FE INVISIBILITY")
local feInvisOn=false
local feInvisData=nil
local feInvisHeight=300
mkTog(MainPage,"FE Invisible (300 up)",function(on)
    feInvisOn=on
    if on then
        local ch=getCh()
        local hrp=ch:WaitForChild("HumanoidRootPart",5)
        local torso=ch:FindFirstChild("Torso") or ch:FindFirstChild("UpperTorso")
        local hm=ch:FindFirstChildOfClass("Humanoid")
        if not hrp or not torso or not hm then
            notify("Character not ready")
            return
        end
        local savedCF=hrp.CFrame
        local hiddenPos=savedCF.Position + Vector3.new(0, feInvisHeight, 0)
        local seat=Instance.new("Seat")
        seat.Name="RichieFEChair"
        seat.Anchored=false
        seat.CanCollide=false
        seat.Transparency=1
        seat.Size=Vector3.new(2,0.4,2)
        seat.Position=hiddenPos
        seat.Parent=W
        local weld=Instance.new("Weld")
        weld.Part0=seat
        weld.Part1=torso
        weld.Parent=seat
        task.wait(0.05)
        seat.CFrame=savedCF
        task.wait(0.1)
        feInvisData={seat=seat, savedCF=savedCF, hm=hm}
        for _,p in pairs(ch:GetDescendants()) do
            if p:IsA("BasePart") and p.Name~="HumanoidRootPart" then
                p.Transparency=1
            end
        end
        if hm then
            hm.DisplayDistanceType=Enum.HumanoidDisplayDistanceType.None
        end
        notify("FE Invisible: ON")
    else
        if feInvisData and feInvisData.seat then
            feInvisData.seat:Destroy()
        end
        local ch=LP.Character
        if ch then
            for _,p in pairs(ch:GetDescendants()) do
                if p:IsA("BasePart") then
                    p.Transparency=0
                end
            end
            local hm=ch:FindFirstChildOfClass("Humanoid")
            if hm then
                hm.DisplayDistanceType=Enum.HumanoidDisplayDistanceType.Viewer
            end
        end
        feInvisData=nil
        notify("FE Invisible: OFF")
    end
end)
mkNum(MainPage,"FE Invis Height","feInvisHeight",300,function(v) feInvisHeight=v end)

mkLabel(MainPage,"CHARACTER CUSTOMIZER")

local origSizeCache = {}
local function cacheCharacter(ch)
    if not ch then return end
    origSizeCache[ch] = {}
    for _,p in pairs(ch:GetDescendants()) do
        if p:IsA("BasePart") then
            origSizeCache[ch][p] = p.Size
        end
    end
end
if LP.Character then cacheCharacter(LP.Character) end
LP.CharacterAdded:Connect(function(ch)
    task.wait(1)
    cacheCharacter(ch)
end)

local function applySize(scale)
    local ch = LP.Character
    if not ch then return end
    local hm = ch:FindFirstChildOfClass("Humanoid")
    if not hm then return end
    local isR15 = ch:FindFirstChild("UpperTorso") ~= nil
    if isR15 then
        hm.BodyDepthScale.Value = scale
        hm.BodyHeightScale.Value = scale
        hm.BodyWidthScale.Value = scale
        hm.HeadScale.Value = scale
    else
        local cache = origSizeCache[ch]
        if not cache then
            cacheCharacter(ch)
            cache = origSizeCache[ch]
        end
        for part, origSize in pairs(cache) do
            if part and part.Parent then
                part.Size = origSize * scale
            end
        end
    end
end

local sizeRow = Instance.new("Frame")
sizeRow.Size = UDim2.new(1,-6,0,34)
sizeRow.BackgroundTransparency = 1
sizeRow.Parent = MainPage
local sizeLayout = Instance.new("UIListLayout", sizeRow)
sizeLayout.FillDirection = Enum.FillDirection.Horizontal
sizeLayout.Padding = UDim.new(0,4)

for _, preset in ipairs({{"Tiny",0.5},{"Normal",1},{"Big",1.5},{"Giant",2.5}}) do
    local b = Instance.new("TextButton")
    b.Size = UDim2.new(0.25,-3,1,0)
    b.BackgroundColor3 = Color3.fromRGB(30,30,36)
    b.BackgroundTransparency = 0.2
    b.Text = preset[1]
    b.TextColor3 = Color3.fromRGB(220,220,220)
    b.Font = Enum.Font.GothamBold
    b.TextSize = 12
    b.BorderSizePixel = 0
    b.AutoButtonColor = false
    b.Parent = sizeRow
    Instance.new("UICorner",b).CornerRadius = UDim.new(0,6)
    b.MouseButton1Click:Connect(function()
        T:Create(b,TweenInfo.new(0.1),{BackgroundColor3=Color3.fromRGB(80,200,120)}):Play()
        task.wait(0.15)
        T:Create(b,TweenInfo.new(0.15),{BackgroundColor3=Color3.fromRGB(30,30,36)}):Play()
        applySize(preset[2])
        notify("Size: "..preset[1])
    end)
end

mkLabel(MainPage,"PROTECTION")

local antVoidOn=false
local antVoidC
mkTog(MainPage,"Anti-Void",function(on)
    antVoidOn=on
    if on then
        antVoidC=R.Heartbeat:Connect(function()
            if not antVoidOn then return end
            local ch=LP.Character
            if ch and ch:FindFirstChild("HumanoidRootPart") then
                if ch.HumanoidRootPart.Position.Y < -50 then
                    ch.HumanoidRootPart.CFrame=CFrame.new(0,50,0)
                end
            end
        end)
    else
        if antVoidC then antVoidC:Disconnect() antVoidC=nil end
    end
end)

local selfAntiFlingOn=false
local selfAntiFlingC
mkTog(MainPage,"Anti-Fling (Self)",function(on)
    selfAntiFlingOn=on
    if on then
        selfAntiFlingC=R.Heartbeat:Connect(function()
            if not selfAntiFlingOn then return end
            local ch=LP.Character
            if ch and ch:FindFirstChild("HumanoidRootPart") then
                local v=ch.HumanoidRootPart.Velocity
                if v.Magnitude > 200 then
                    ch.HumanoidRootPart.Velocity=Vector3.new(0,0,0)
                end
            end
        end)
    else
        if selfAntiFlingC then selfAntiFlingC:Disconnect() selfAntiFlingC=nil end
    end
end)

local function teleportToMouse()
    local ch=LP.Character
    if not ch then return end
    local hrp=ch:FindFirstChild("HumanoidRootPart")
    if not hrp then return end
    local mouse = LP:GetMouse()
    if mouse and mouse.Hit then
        hrp.CFrame = mouse.Hit + Vector3.new(0,3,0)
        notify("Teleported")
    else
        notify("No mouse (PC only)")
    end
end

local uiHidden=false
U.InputBegan:Connect(function(input, gp)
    if gp then return end
    if input.KeyCode == Enum.KeyCode.RightShift then
        uiHidden = not uiHidden
        M.Visible = not uiHidden
        RestoreBtn.Visible = false
        if uiHidden then
            RestoreBtn.Position = UDim2.new(0,10,0,10)
            RestoreBtn.Visible = true
        end
    end
end)

mkLabel(MainPage,"ACTIONS")
mkBtn(MainPage,"Reset Character",function()
    local ch=LP.Character
    if ch and ch:FindFirstChild("Humanoid") then ch.Humanoid.Health=0 end
end)
mkBtn(MainPage,"Rejoin Server",function()
    game:GetService("TeleportService"):Teleport(game.PlaceId, LP)
end)
end
-- ============ COMBAT TAB ============
do
mkLabel(CombatPage,"AIM ASSIST")

local aimAssistOn = false
local aimFovCircleOn = false
local aimStrength = 50
local aimSmoothing = 30
local aimFov = 90
local aimBone = "Head"
local aimPriority = "Nearest"
local teamCheckOn = false
local wallCheckOn = false
local triggerBotOn = false
local triggerDelay = 0.1
local targetLockOn = false
local lockBone = "Head"
local holdKeyOn = false
local aimKeybind = Enum.KeyCode.RightAlt

local function getPlayerTeam(p)
    return p.Team
end

local function isTeammate(p)
    if not teamCheckOn then return false end
    if not LP.Team then return false end
    if not p.Team then return false end
    return LP.Team == p.Team
end

local function getBodyPart(char, boneName)
    if not char then return nil end
    if boneName == "Head" then
        return char:FindFirstChild("Head") or char:FindFirstChild("UpperTorso") or char:FindFirstChild("Torso")
    else
        return char:FindFirstChild("UpperTorso") or char:FindFirstChild("Torso") or char:FindFirstChild("Head")
    end
end

local function isVisibleFromCamera(part)
    if not wallCheckOn then return true end
    if not part then return false end
    local cam = C
    local origin = cam.CFrame.Position
    local targetPos = part.Position
    local dir = (targetPos - origin)
    local params = RaycastParams.new()
    params.FilterType = Enum.RaycastFilterType.Exclude
    params.FilterDescendantsInstances = {LP.Character}
    local result = W:Raycast(origin, dir, params)
    if not result then return true end
    return result.Instance:IsDescendantOf(part.Parent)
end

local function getPriorityPlayer(players)
    if #players == 0 then return nil end
    if aimPriority == "Nearest" then
        local myHrp = LP.Character and LP.Character:FindFirstChild("HumanoidRootPart")
        if not myHrp then return players[1] end
        local best, bestDist = nil, math.huge
        for _, p in pairs(players) do
            local hrp = p.Character and p.Character:FindFirstChild("HumanoidRootPart")
            if hrp then
                local d = (hrp.Position - myHrp.Position).Magnitude
                if d < bestDist then best, bestDist = p, d end
            end
        end
        return best
    elseif aimPriority == "Lowest HP" then
        local best, bestHP = nil, math.huge
        for _, p in pairs(players) do
            local hm = p.Character and p.Character:FindFirstChildOfClass("Humanoid")
            if hm and hm.Health < bestHP then best, bestHP = p, hm.Health end
        end
        return best
    elseif aimPriority == "Closest to Crosshair" then
        local best, bestDist = nil, math.huge
        local center = C.ViewportSize / 2
        for _, p in pairs(players) do
            local part = getBodyPart(p.Character, aimBone)
            if part then
                local sp, onScreen = C:WorldToViewportPoint(part.Position)
                if onScreen then
                    local d = (Vector2.new(sp.X, sp.Y) - center).Magnitude
                    if d < bestDist then best, bestDist = p, d end
                end
            end
        end
        return best
    end
    return players[1]
end

local function getPlayersInFov()
    local list = {}
    local center = C.ViewportSize / 2
    for _, p in pairs(P:GetPlayers()) do
        if p ~= LP and p.Character then
            if not isTeammate(p) then
                local part = getBodyPart(p.Character, aimBone)
                if part and isVisibleFromCamera(part) then
                    local sp, onScreen = C:WorldToViewportPoint(part.Position)
                    if onScreen then
                        local d = (Vector2.new(sp.X, sp.Y) - center).Magnitude
                        if d <= aimFov then
                            table.insert(list, p)
                        end
                    end
                end
            end
        end
    end
    return list
end

local aimPredictionOn = false
local predictionAmount = 0.15
local aimAssistConn = nil
local function startAimAssist()
    if aimAssistConn then aimAssistConn:Disconnect() end
    aimAssistConn = R.RenderStepped:Connect(function()
        if not aimAssistOn then return end
        if holdKeyOn and not U:IsKeyDown(aimKeybind) then return end
        local list = getPlayersInFov()
        local target = getPriorityPlayer(list)
        if target and target.Character then
            local part = getBodyPart(target.Character, aimBone)
            if part then
                local camPos = C.CFrame.Position
                local aimPos = part.Position
if aimPredictionOn then
    local targetHrp = target.Character:FindFirstChild("HumanoidRootPart")
    if targetHrp then
        aimPos = aimPos + (targetHrp.Velocity * predictionAmount)
    end
end
local desiredCF = CFrame.new(camPos, aimPos)
                local strength = aimStrength / 100
                local smooth = (100 - aimSmoothing) / 100
                local tween = strength * smooth
                C.CFrame = C.CFrame:Lerp(desiredCF, tween)
            end
        end
    end)
end

mkTog(CombatPage,"Aim Assist",function(on)
    aimAssistOn = on
    if on then startAimAssist() notify("Aim Assist: ON") else notify("Aim Assist: OFF") end
end)

mkTog(CombatPage,"Hold Key to Aim",function(on)
    holdKeyOn = on
    notify("Hold to Aim: "..(on and "ON" or "OFF"))
end)

mkNum(CombatPage,"Aim Strength","aimStrength",50,function(v) aimStrength = math.clamp(v,0,100) end)
mkNum(CombatPage,"Aim Smoothing","aimSmoothing",30,function(v) aimSmoothing = math.clamp(v,0,100) end)
mkNum(CombatPage,"Aim FOV Radius","aimFov",90,function(v) aimFov = math.clamp(v,10,500) end)
mkTog(CombatPage,"Aim Prediction",function(on)
    aimPredictionOn = on
    notify("Aim Prediction: "..(on and "ON" or "OFF"))
end)
mkNum(CombatPage,"Prediction Amount","predictionAmount",0.15,function(v) predictionAmount = math.clamp(v,0,0.5) end)

-- Bone selector buttons
local boneRow = Instance.new("Frame")
boneRow.Size = UDim2.new(1,-6,0,34)
boneRow.BackgroundTransparency = 1
boneRow.Parent = CombatPage
local boneLayout = Instance.new("UIListLayout",boneRow)
boneLayout.FillDirection = Enum.FillDirection.Horizontal
boneLayout.Padding = UDim.new(0,4)

for _,opt in ipairs({"Head","Torso"}) do
    local b = Instance.new("TextButton")
    b.Size = UDim2.new(0.5,-2,1,0)
    b.BackgroundColor3 = (aimBone==opt) and Color3.fromRGB(80,200,120) or Color3.fromRGB(30,30,36)
    b.Text = "Aim: "..opt
    b.TextColor3 = Color3.fromRGB(220,220,220)
    b.Font = Enum.Font.GothamBold
    b.TextSize = 12
    b.BorderSizePixel = 0
    b.AutoButtonColor = false
    b.Parent = boneRow
    Instance.new("UICorner",b).CornerRadius = UDim.new(0,6)
    b.MouseButton1Click:Connect(function()
        aimBone = opt
        for _,c in pairs(boneRow:GetChildren()) do
            if c:IsA("TextButton") then
                c.BackgroundColor3 = (c.Text=="Aim: "..opt) and Color3.fromRGB(80,200,120) or Color3.fromRGB(30,30,36)
            end
        end
        notify("Aim Bone: "..opt)
    end)
end

-- Priority selector
local prioRow = Instance.new("Frame")
prioRow.Size = UDim2.new(1,-6,0,34)
prioRow.BackgroundTransparency = 1
prioRow.Parent = CombatPage
local prioLayout = Instance.new("UIListLayout",prioRow)
prioLayout.FillDirection = Enum.FillDirection.Horizontal
prioLayout.Padding = UDim.new(0,4)

for _,opt in ipairs({"Nearest","Lowest HP","Closest to Crosshair"}) do
    local b = Instance.new("TextButton")
    b.Size = UDim2.new(0.333,-3,1,0)
    b.BackgroundColor3 = (aimPriority==opt) and Color3.fromRGB(80,200,120) or Color3.fromRGB(30,30,36)
    b.Text = opt
    b.TextColor3 = Color3.fromRGB(220,220,220)
    b.Font = Enum.Font.GothamBold
    b.TextSize = 10
    b.BorderSizePixel = 0
    b.AutoButtonColor = false
    b.Parent = prioRow
    Instance.new("UICorner",b).CornerRadius = UDim.new(0,6)
    b.MouseButton1Click:Connect(function()
        aimPriority = opt
        for _,c in pairs(prioRow:GetChildren()) do
            if c:IsA("TextButton") then
                c.BackgroundColor3 = (c.Text==opt) and Color3.fromRGB(80,200,120) or Color3.fromRGB(30,30,36)
            end
        end
        notify("Priority: "..opt)
    end)
end

mkTog(CombatPage,"Team Check",function(on)
    teamCheckOn = on
    notify("Team Check: "..(on and "ON" or "OFF"))
end)

mkTog(CombatPage,"Wall Check",function(on)
    wallCheckOn = on
    notify("Wall Check: "..(on and "ON" or "OFF"))
end)

-- FOV Circle
local aimFovGui = Instance.new("ScreenGui")
aimFovGui.Name = "RichieAimFov"
aimFovGui.ResetOnSpawn = false
aimFovGui.IgnoreGuiInset = true
aimFovGui.Parent = pg

local aimFovCircle = Instance.new("Frame")
aimFovCircle.Size = UDim2.new(0,180,0,180)
aimFovCircle.Position = UDim2.new(0.5,-90,0.5,-90)
aimFovCircle.BackgroundTransparency = 1
aimFovCircle.Visible = false
aimFovCircle.Parent = aimFovGui
Instance.new("UICorner",aimFovCircle).CornerRadius = UDim.new(1,0)

local aimFovStroke = Instance.new("UIStroke",aimFovCircle)
aimFovStroke.Thickness = 2
aimFovStroke.Color = Color3.fromRGB(80,200,255)
aimFovStroke.Transparency = 0.3

mkTog(CombatPage,"Aim FOV Circle",function(on)
    aimFovCircleOn = on
    aimFovCircle.Visible = on
    notify("Aim FOV Circle: "..(on and "ON" or "OFF"))
end)

task.spawn(function()
    while true do
        task.wait(0.1)
        if aimFovCircleOn then
            local sz = aimFov * 2
            aimFovCircle.Size = UDim2.new(0,sz,0,sz)
            aimFovCircle.Position = UDim2.new(0.5,-sz/2,0.5,-sz/2)
        end
    end
end)

-- Target Lock
local lockConn = nil
local function startLock()
    if lockConn then lockConn:Disconnect() end
    lockConn = R.RenderStepped:Connect(function()
        if not targetLockOn then return end
        local list = getPlayersInFov()
        local target = getPriorityPlayer(list)
        if target and target.Character then
            local part = getBodyPart(target.Character, lockBone)
            if part then
                C.CFrame = CFrame.new(C.CFrame.Position, part.Position)
            end
        end
    end)
end

mkTog(CombatPage,"Target Lock",function(on)
    targetLockOn = on
    if on then startLock() notify("Target Lock: ON") else notify("Target Lock: OFF") end
end)

-- Trigger Bot
local antiAimOn = false
local antiAimConn = nil
local antiAimSpeed = 0.05

local function startAntiAim()
    if antiAimConn then antiAimConn:Disconnect() end
    antiAimConn = R.RenderStepped:Connect(function()
        if not antiAimOn then return end
        local ch = LP.Character
        if not ch then return end
        local hrp = ch:FindFirstChild("HumanoidRootPart")
        local neck = ch:FindFirstChild("Neck")
        if not neck or not hrp then return end
        if neck:IsA("Motor6D") then
            local t = tick() * (1 / antiAimSpeed)
            local jitter = math.sin(t) * 90
            neck.C0 = CFrame.new(neck.C0.Position) * CFrame.Angles(0, math.rad(jitter), 0)
        end
    end)
end
local triggerConn = nil
local wasFiring = false
local lastShot = 0
local function startTriggerBot()
    if triggerConn then triggerConn:Disconnect() end
    triggerConn = R.RenderStepped:Connect(function()
        if not triggerBotOn then return end
        if tick() - lastShot < triggerDelay then return end

        local viewportSize = C.ViewportSize
        local screenCenter = viewportSize / 2
        local list = getPlayersInFov()
        local targetFound = false

        for _, p in pairs(list) do
            if p.Character then
                local part = getBodyPart(p.Character, aimBone)
                if part then
                    local sp, onScreen = C:WorldToViewportPoint(part.Position)
                    if onScreen then
                        local d = (Vector2.new(sp.X, sp.Y) - screenCenter).Magnitude
                        if d < 20 then
                            targetFound = true
                            local tool = LP.Character and LP.Character:FindFirstChildOfClass("Tool")
                            if tool then
                                pcall(function() tool:Activate() end)
                                lastShot = tick()
                            end
                            break
                        end
                    end
                end
            end
        end

        -- If no target under crosshair → release mouse to stop firing
        if targetFound then
    wasFiring = true
elseif wasFiring then
    wasFiring = false
            pcall(function()
                local vu = game:GetService("VirtualUser")
                vu:Button1Up(Vector2.new(0,0), C.CFrame)
            end)
        end
    end)
end

mkTog(CombatPage,"Trigger Bot",function(on)
    triggerBotOn = on
    if not on then
        if triggerConn then
            triggerConn:Disconnect()
            triggerConn = nil
        end
    end
end)

mkTog(CombatPage,"Anti-Aim",function(on)
    antiAimOn = on
    if on then startAntiAim() notify("Anti-Aim: ON") else notify("Anti-Aim: OFF") end
end)

mkNum(CombatPage,"Anti-Aim Speed","antiAimSpeed",0.05,function(v) antiAimSpeed = math.clamp(v,0.01,1) end)

-- Hitbox Expander (moved from Visuals)
mkLabel(CombatPage,"HITBOX")

local hitboxOn = false
local hitboxSize = 5
local hitboxConns = {}

local function restoreHitbox(p)
    local char = p.Character
    if not char then return end
    local hrp = char:FindFirstChild("HumanoidRootPart")
    if hrp and hrp:GetAttribute("RichieHitboxOrig") then
        hrp.Size = hrp:GetAttribute("RichieHitboxOrig")
    end
    for _, part in pairs(char:GetDescendants()) do
        if part:IsA("BasePart") and part:GetAttribute("RichieHitboxOrig") then
            part.Size = part:GetAttribute("RichieHitboxOrig")
            local masslessAttr = part:GetAttribute("RichieHitboxOrigMassless")
            local canCollideAttr = part:GetAttribute("RichieHitboxOrigCanCollide")
            if masslessAttr ~= nil then part.Massless = masslessAttr end
            if canCollideAttr ~= nil then part.CanCollide = canCollideAttr end
        end
    end
end

local function applyHitbox(p)
    if p == LP then return end
    local char = p.Character
    if not char then return end
    local hrp = char:FindFirstChild("HumanoidRootPart")
    if hrp then
        if not hrp:GetAttribute("RichieHitboxOrig") then
            hrp:SetAttribute("RichieHitboxOrig", hrp.Size)
        end
        hrp.Size = hrp:GetAttribute("RichieHitboxOrig") + Vector3.new(hitboxSize, hitboxSize, hitboxSize)
    end
    for _, part in pairs(char:GetDescendants()) do
        if part:IsA("BasePart") and part ~= hrp and part.Name ~= "HumanoidRootPart" then
            if not part:GetAttribute("RichieHitboxOrig") then
                part:SetAttribute("RichieHitboxOrig", part.Size)
                part:SetAttribute("RichieHitboxOrigMassless", part.Massless)
                part:SetAttribute("RichieHitboxOrigCanCollide", part.CanCollide)
            end
            local orig = part:GetAttribute("RichieHitboxOrig")
            part.Size = orig + Vector3.new(hitboxSize, hitboxSize, hitboxSize)
            part.CanCollide = false
            part.Massless = true
        end
    end
end

mkTog(CombatPage,"Hitbox Expander",function(on)
    hitboxOn = on
    for _, c in pairs(hitboxConns) do c:Disconnect() end
    hitboxConns = {}
    if on then
        for _, p in pairs(P:GetPlayers()) do
            if p ~= LP then
                applyHitbox(p)
                local c = p.CharacterAdded:Connect(function()
                    task.wait(0.5)
                    if hitboxOn then applyHitbox(p) end
                end)
                table.insert(hitboxConns, c)
            end
        end
        local newConn = P.PlayerAdded:Connect(function(p)
            local c = p.CharacterAdded:Connect(function()
                task.wait(0.5)
                if hitboxOn then applyHitbox(p) end
            end)
            table.insert(hitboxConns, c)
        end)
        table.insert(hitboxConns, newConn)
        notify("Hitbox Expander: ON")
    else
        for _, p in pairs(P:GetPlayers()) do
            if p ~= LP then restoreHitbox(p) end
        end
        notify("Hitbox Expander: OFF")
    end
end)

mkNum(CombatPage,"Hitbox Size","hitboxSize",5,function(v)
    hitboxSize = math.clamp(tonumber(v) or 5, 0, 50)
    if hitboxOn then
        for _, p in pairs(P:GetPlayers()) do
            if p ~= LP then
                restoreHitbox(p)
                applyHitbox(p)
            end
        end
    end
end)

local hitboxEspOn = false
local hitboxEspFolders = {}

local function updateHitboxEsp()
    for p, folder in pairs(hitboxEspFolders) do
        if not p.Character or not hitboxEspOn then
            if folder then folder:Destroy() end
            hitboxEspFolders[p] = nil
        end
    end
    if not hitboxEspOn then return end
    for _, p in pairs(P:GetPlayers()) do
        if p ~= LP and p.Character then
            local hrp = p.Character:FindFirstChild("HumanoidRootPart")
            if hrp then
                local folder = hitboxEspFolders[p]
                if not folder or not folder.Parent then
                    folder = Instance.new("Folder")
                    folder.Name = "RichieHitboxEsp"
                    folder.Parent = W
                    local box = Instance.new("SelectionBox")
                    box.Name = "HitboxBox"
                    box.Color3 = Color3.fromRGB(255, 80, 80)
                    box.LineThickness = 0.05
                    box.Transparency = 0.3
                    box.Adornee = hrp
                    box.Parent = folder
                    hitboxEspFolders[p] = folder
                end
                local box = folder:FindFirstChild("HitboxBox")
                if box then
                    box.Adornee = hrp
                    box.Visible = true
                end
            end
        end
    end
end

mkTog(CombatPage,"Hitbox ESP Preview",function(on)
    hitboxEspOn = on
    if not on then
        for p, folder in pairs(hitboxEspFolders) do
            if folder then folder:Destroy() end
        end
        hitboxEspFolders = {}
    else
        updateHitboxEsp()
    end
    notify("Hitbox ESP: "..(on and "ON" or "OFF"))
end)

task.spawn(function()
    while true do
        task.wait(0.5)
        if hitboxEspOn then updateHitboxEsp() end
    end
end)
_G.richieCombatCleanup = function()
    if aimAssistConn then aimAssistConn:Disconnect() end
    if lockConn then lockConn:Disconnect() end
    if triggerConn then triggerConn:Disconnect() end
    if antiAimConn then antiAimConn:Disconnect() end
    for _, c in pairs(hitboxConns) do c:Disconnect() end
    for _, folder in pairs(hitboxEspFolders) do if folder then folder:Destroy() end end
end
end


-- ============ VISUALS ============
do
local espColors = {
    esp = {r=150, g=150, b=150},
    box = {r=255, g=80, b=80},
    name = {r=255, g=80, b=80},
    dist = {r=80, g=255, b=80},
fov = {r=255, g=80, b=80},
skel = {r=255, g=255, b=255}
}
_G.richieEspColors = espColors
local function rgbC(t) return Color3.fromRGB(t.r, t.g, t.b) end

mkLabel(VisualsPage,"ESP")
local espOn=false
local espH={}
local espConns={}
local function addEspToPlayer(p)
    if not espOn or p==LP or not p.Character then return end
    if espH[p] and espH[p].Parent then return end
    local char = p.Character
    if not char:FindFirstChildWhichIsA("BasePart") then return end
    local hl=Instance.new("Highlight")
    local ec=_G.richieEspColors and _G.richieEspColors.esp; hl.FillColor=ec and Color3.fromRGB(ec.r,ec.g,ec.b) or Color3.fromRGB(150,150,150)
    hl.OutlineColor=Color3.fromRGB(255,255,255)
    hl.FillTransparency=0.5
    hl.Adornee=char
    hl.Parent=char
    espH[p]=hl
end
mkTog(VisualsPage,"ESP (Grey)",function(on)
    espOn=on
    if on then
        for _,p in pairs(P:GetPlayers()) do addEspToPlayer(p) end
        for _,p in pairs(P:GetPlayers()) do
            if p~=LP then
                local c=p.CharacterAdded:Connect(function()
                    task.wait(0.5)
                    if espH[p] then espH[p]:Destroy() espH[p]=nil end
                    addEspToPlayer(p)
                end)
                table.insert(espConns,c)
            end
        end
        local newConn=P.PlayerAdded:Connect(function(p)
            local c=p.CharacterAdded:Connect(function()
                task.wait(0.5) addEspToPlayer(p)
            end)
            table.insert(espConns,c)
        end)
        table.insert(espConns,newConn)
    else
        for _,c in pairs(espConns) do c:Disconnect() end
        espConns={}
        for _,hl in pairs(espH) do if hl then hl:Destroy() end end
        espH={}
    end
end)

local boxOn=false
local boxGuis={}
local boxConns={}
local function addBox(p)
    if not boxOn or p==LP or not p.Character then return end
    if boxGuis[p] and boxGuis[p].Parent then return end
    local char = p.Character
    local hrp = char:FindFirstChild("HumanoidRootPart")
        or char:FindFirstChild("UpperTorso")
        or char:FindFirstChild("Torso")
        or char:FindFirstChildWhichIsA("BasePart")
    if not hrp then return end
    local bg=Instance.new("BillboardGui")
    bg.Size=UDim2.new(0,40,0,60)
    bg.AlwaysOnTop=true
    bg.Adornee=hrp
    bg.Parent=hrp
    local fr=Instance.new("Frame")
    fr.Size=UDim2.new(1,0,1,0)
    fr.BackgroundTransparency=1
    fr.Parent=bg
    local stroke=Instance.new("UIStroke",fr)
    stroke.Thickness=2
    stroke.Color=Color3.fromRGB(255,80,80)
    Instance.new("UICorner",fr).CornerRadius=UDim.new(0,6)
    boxGuis[p]=bg
end
mkTog(VisualsPage,"Box ESP",function(on)
    boxOn=on
    if on then
        for _,p in pairs(P:GetPlayers()) do addBox(p) end
        for _,p in pairs(P:GetPlayers()) do
            if p~=LP then
                local c=p.CharacterAdded:Connect(function()
                    task.wait(0.5)
                    if boxGuis[p] then boxGuis[p]:Destroy() boxGuis[p]=nil end
                    addBox(p)
                end)
                table.insert(boxConns,c)
            end
        end
        local newConn=P.PlayerAdded:Connect(function(p)
            local c=p.CharacterAdded:Connect(function()
                task.wait(0.5) addBox(p)
            end)
            table.insert(boxConns,c)
        end)
        table.insert(boxConns,newConn)
    else
        for _,c in pairs(boxConns) do c:Disconnect() end
        boxConns={}
        for _,bg in pairs(boxGuis) do if bg then bg:Destroy() end end
        boxGuis={}
    end
end)

local healthOn=false
local healthTags={}
local healthConns={}
local function addHealthTag(p)
    if not healthOn or p==LP or not p.Character then return end
    if healthTags[p] and healthTags[p].gui and healthTags[p].gui.Parent then return end
    local char = p.Character
    local hrp = char:FindFirstChild("HumanoidRootPart")
        or char:FindFirstChild("UpperTorso")
        or char:FindFirstChild("Torso")
        or char:FindFirstChildWhichIsA("BasePart")
    local hm=char:FindFirstChild("Humanoid") or char:FindFirstChildOfClass("Humanoid")
    if not hrp or not hm then return end
    local bg=Instance.new("BillboardGui")
    bg.Size=UDim2.new(0,50,0,6)
    bg.StudsOffset=Vector3.new(0,-3,0)
    bg.AlwaysOnTop=true
    bg.Adornee=hrp
    bg.Parent=hrp
    local fill=Instance.new("Frame")
    fill.Size=UDim2.new(hm.Health/hm.MaxHealth,0,1,0)
    fill.BackgroundColor3=Color3.fromRGB(80,255,80)
    fill.BorderSizePixel=0
    fill.Parent=bg
    Instance.new("UICorner",fill).CornerRadius=UDim.new(1,0)
    local hpChange=hm.HealthChanged:Connect(function(h)
        fill.Size=UDim2.new(math.clamp(h/hm.MaxHealth,0,1),0,1,0)
        if h/hm.MaxHealth<0.3 then
            fill.BackgroundColor3=Color3.fromRGB(255,80,80)
        elseif h/hm.MaxHealth<0.6 then
            fill.BackgroundColor3=Color3.fromRGB(255,220,80)
        else
            fill.BackgroundColor3=Color3.fromRGB(80,255,80)
        end
    end)
    healthTags[p]={gui=bg,conn=hpChange}
end
mkTog(VisualsPage,"Health Bar ESP",function(on)
    healthOn=on
    if on then
        for _,p in pairs(P:GetPlayers()) do addHealthTag(p) end
        for _,p in pairs(P:GetPlayers()) do
            if p~=LP then
                local c=p.CharacterAdded:Connect(function()
                    task.wait(0.5)
                    if healthTags[p] then
                        if healthTags[p].gui then healthTags[p].gui:Destroy() end
                        if healthTags[p].conn then healthTags[p].conn:Disconnect() end
                        healthTags[p]=nil
                    end
                    addHealthTag(p)
                end)
                table.insert(healthConns,c)
            end
        end
        local newConn=P.PlayerAdded:Connect(function(p)
            local c=p.CharacterAdded:Connect(function()
                task.wait(0.5) addHealthTag(p)
            end)
            table.insert(healthConns,c)
        end)
        table.insert(healthConns,newConn)
    else
        for _,c in pairs(healthConns) do c:Disconnect() end
        healthConns={}
        for p,data in pairs(healthTags) do
            if data.gui then data.gui:Destroy() end
            if data.conn then data.conn:Disconnect() end
        end
        healthTags={}
    end
end)

local fovCircleGui=Instance.new("ScreenGui")
fovCircleGui.Name="RichieFovCircle"
fovCircleGui.ResetOnSpawn=false
fovCircleGui.IgnoreGuiInset=true
fovCircleGui.Parent=pg

local fovCircle=Instance.new("Frame")
fovCircle.Size=UDim2.new(0,200,0,200)
fovCircle.Position=UDim2.new(0.5,-100,0.5,-100)
fovCircle.BackgroundTransparency=1
fovCircle.BorderSizePixel=0
fovCircle.Visible=false
fovCircle.Parent=fovCircleGui
Instance.new("UICorner",fovCircle).CornerRadius=UDim.new(1,0)

local fovStroke=Instance.new("UIStroke",fovCircle)
fovStroke.Thickness=2
fovStroke.Color=Color3.fromRGB(255,80,80)
fovStroke.Transparency=0.2

mkTog(VisualsPage,"FOV Circle",function(on)
fovStroke.Color = rgbC(espColors.fov)
    fovCircle.Visible=on
end)

local skeletonOn=false
local skeletonData={}
local skeletonConns={}

local bones={
    {"Head","UpperTorso"},
    {"UpperTorso","LowerTorso"},
    {"UpperTorso","LeftUpperArm"},
    {"LeftUpperArm","LeftLowerArm"},
    {"LeftLowerArm","LeftHand"},
    {"UpperTorso","RightUpperArm"},
    {"RightUpperArm","RightLowerArm"},
    {"RightLowerArm","RightHand"},
    {"LowerTorso","LeftUpperLeg"},
    {"LeftUpperLeg","LeftLowerLeg"},
    {"LeftLowerLeg","LeftFoot"},
    {"LowerTorso","RightUpperLeg"},
    {"RightUpperLeg","RightLowerLeg"},
    {"RightLowerLeg","RightFoot"},
}

local bonesR6={
    {"Head","Torso"},
    {"Torso","Left Arm"},
    {"Torso","Right Arm"},
    {"Torso","Left Leg"},
    {"Torso","Right Leg"},
}

local function addSkeleton(p)
    if not skeletonOn or p==LP or not p.Character then return end
    if skeletonData[p] then return end
    local char=p.Character
    local isR15 = char:FindFirstChild("UpperTorso") ~= nil
    local boneList = isR15 and bones or bonesR6
    local lines={}
    for _=1,#boneList do
        local line = Drawing.new("Line")
        line.Visible=false
        line.Color=rgbC(espColors.skel)
        line.Thickness=1
        line.Transparency=1
        table.insert(lines, line)
    end
    skeletonData[p]={lines=lines, boneList=boneList}
end

task.spawn(function()
    while true do
        if skeletonOn then
            local cam=C
            for p,data in pairs(skeletonData) do
                local char = p.Character
                if char then
                    for i,bone in pairs(data.boneList) do
                        local part1=char:FindFirstChild(bone[1])
                        local part2=char:FindFirstChild(bone[2])
                        local line=data.lines[i]
                        if part1 and part2 and line then
                            local pos1,on1=cam:WorldToViewportPoint(part1.Position)
                            local pos2,on2=cam:WorldToViewportPoint(part2.Position)
                            if on1 and on2 and pos1.Z>0 and pos2.Z>0 then
                                line.From=Vector2.new(pos1.X, pos1.Y)
                                line.To=Vector2.new(pos2.X, pos2.Y)
                                line.Visible=true
                            else
                                line.Visible=false
                            end
                        elseif line then
                            line.Visible=false
                        end
                    end
                end
            end
        end
        task.wait()
    end
end)

mkTog(VisualsPage,"Skeleton ESP",function(on)
    skeletonOn=on
    if on then
        for _,p in pairs(P:GetPlayers()) do addSkeleton(p) end
        for _,p in pairs(P:GetPlayers()) do
            if p~=LP then
                local c=p.CharacterAdded:Connect(function()
                    task.wait(0.5)
                    if skeletonData[p] then
                        for _,line in pairs(skeletonData[p].lines) do line:Remove() end
                        skeletonData[p]=nil
                    end
                    addSkeleton(p)
                end)
                table.insert(skeletonConns,c)
            end
        end
        local newConn=P.PlayerAdded:Connect(function(p)
            local c=p.CharacterAdded:Connect(function()
                task.wait(0.5) addSkeleton(p)
            end)
            table.insert(skeletonConns,c)
        end)
        table.insert(skeletonConns,newConn)
    else
        for _,c in pairs(skeletonConns) do c:Disconnect() end
        skeletonConns={}
        for p,data in pairs(skeletonData) do
            for _,line in pairs(data.lines) do line:Remove() end
        end
        skeletonData={}
    end
end)
local colorPalette = {
    {name="Red", r=255, g=0, b=0},
    {name="Orange", r=255, g=140, b=0},
    {name="Yellow", r=255, g=255, b=0},
    {name="Lime", r=0, g=255, b=0},
    {name="Green", r=0, g=180, b=0},
    {name="Cyan", r=0, g=255, b=255},
    {name="Sky Blue", r=80, g=180, b=255},
    {name="Blue", r=0, g=80, b=255},
    {name="Purple", r=140, g=0, b=255},
    {name="Magenta", r=255, g=0, b=255},
    {name="Pink", r=255, g=105, b=180},
    {name="White", r=255, g=255, b=255},
    {name="Grey", r=150, g=150, b=150},
    {name="Dark Grey", r=60, g=60, b=60},
    {name="Black", r=0, g=0, b=0},
}
local nameTags = {}
local distTags = {}
local waypointMarkers = {}

local function refreshEspColors()
    for _, hl in pairs(espH) do
        if hl and hl.Parent then hl.FillColor = rgbC(espColors.esp) end
    end
    for _, bg in pairs(boxGuis) do
        if bg and bg.Parent then
            local fr = bg:FindFirstChildOfClass("Frame")
            local stroke = fr and fr:FindFirstChildOfClass("UIStroke")
            if stroke then stroke.Color = rgbC(espColors.box) end
        end
    end
    for _, bg in pairs(nameTags) do
        if bg and bg.Parent then
            local lbl = bg:FindFirstChildOfClass("TextLabel")
            if lbl then lbl.TextColor3 = rgbC(espColors.name) end
        end
    end
    if fovStroke then fovStroke.Color = rgbC(espColors.fov) end
for _, data in pairs(skeletonData) do
    if data and data.lines then
        for _, line in pairs(data.lines) do
            pcall(function() line.Color = rgbC(espColors.skel) end)
        end
    end
end
end

local function mkColorPicker(parent, label, key)
    local h = Instance.new("Frame")
    h.Size = UDim2.new(1,-6,0,34)
    h.BackgroundColor3 = Color3.fromRGB(30,30,36)
    h.BackgroundTransparency = 0.3
    h.BorderSizePixel = 0
    h.Parent = parent
    Instance.new("UICorner", h).CornerRadius = UDim.new(0,8)

    local lbl = Instance.new("TextLabel")
    lbl.Size = UDim2.new(1,-80,1,0)
    lbl.Position = UDim2.new(0,12,0,0)
    lbl.BackgroundTransparency = 1
    lbl.Text = label
    lbl.TextColor3 = Color3.fromRGB(220,220,220)
    lbl.Font = Enum.Font.GothamSemibold
    lbl.TextSize = 12
    lbl.TextXAlignment = Enum.TextXAlignment.Left
    lbl.Parent = h

    local preview = Instance.new("Frame")
    preview.Size = UDim2.new(0,24,0,24)
    preview.Position = UDim2.new(1,-62,0.5,-12)
    preview.BackgroundColor3 = rgbC(espColors[key])
    preview.BorderSizePixel = 0
    preview.Parent = h
    Instance.new("UICorner", preview).CornerRadius = UDim.new(0,5)
    local previewStroke = Instance.new("UIStroke", preview)
    previewStroke.Thickness = 1
    previewStroke.Color = Color3.fromRGB(80,80,80)

    local arrow = Instance.new("TextLabel")
    arrow.Size = UDim2.new(0,20,1,0)
    arrow.Position = UDim2.new(1,-28,0,0)
    arrow.BackgroundTransparency = 1
    arrow.Text = "▶"
    arrow.TextColor3 = Color3.fromRGB(80,200,120)
    arrow.Font = Enum.Font.GothamBold
    arrow.TextSize = 14
    arrow.Parent = h

    local clickBtn = Instance.new("TextButton")
    clickBtn.Size = UDim2.new(1,0,1,0)
    clickBtn.BackgroundTransparency = 1
    clickBtn.Text = ""
    clickBtn.Parent = h

    local dropdown = Instance.new("Frame")
    dropdown.Size = UDim2.new(1,-6,0, 12 + #colorPalette * 31)
    dropdown.BackgroundColor3 = Color3.fromRGB(25,25,30)
    dropdown.BackgroundTransparency = 0.2
    dropdown.BorderSizePixel = 0
    dropdown.Visible = false
    dropdown.Parent = parent
    Instance.new("UICorner", dropdown).CornerRadius = UDim.new(0,8)
    local dList = Instance.new("UIListLayout", dropdown)
    dList.Padding = UDim.new(0,3)
    dList.SortOrder = Enum.SortOrder.LayoutOrder
    local dPad = Instance.new("UIPadding", dropdown)
    dPad.PaddingTop = UDim.new(0,6)
    dPad.PaddingBottom = UDim.new(0,6)
    dPad.PaddingLeft = UDim.new(0,6)
    dPad.PaddingRight = UDim.new(0,6)

    for i, c in ipairs(colorPalette) do
        local row = Instance.new("TextButton")
        row.Size = UDim2.new(1,0,0,28)
        row.BackgroundColor3 = Color3.fromRGB(35,35,42)
        row.BackgroundTransparency = 0.3
        row.Text = ""
        row.BorderSizePixel = 0
        row.AutoButtonColor = false
        row.LayoutOrder = i
        row.Parent = dropdown
        Instance.new("UICorner", row).CornerRadius = UDim.new(0,5)

        local swatch = Instance.new("Frame")
        swatch.Size = UDim2.new(0,18,0,18)
        swatch.Position = UDim2.new(0,8,0.5,-9)
        swatch.BackgroundColor3 = Color3.fromRGB(c.r, c.g, c.b)
        swatch.BorderSizePixel = 0
        swatch.Parent = row
        Instance.new("UICorner", swatch).CornerRadius = UDim.new(0,4)
        local swStroke = Instance.new("UIStroke", swatch)
        swStroke.Thickness = 1
        swStroke.Color = Color3.fromRGB(80,80,80)

        local nameLbl = Instance.new("TextLabel")
        nameLbl.Size = UDim2.new(1,-40,1,0)
        nameLbl.Position = UDim2.new(0,34,0,0)
        nameLbl.BackgroundTransparency = 1
        nameLbl.Text = c.name
        nameLbl.TextColor3 = Color3.fromRGB(220,220,220)
        nameLbl.Font = Enum.Font.GothamSemibold
        nameLbl.TextSize = 12
        nameLbl.TextXAlignment = Enum.TextXAlignment.Left
        nameLbl.Parent = row

        row.MouseButton1Click:Connect(function()
            espColors[key].r = c.r
            espColors[key].g = c.g
            espColors[key].b = c.b
            savedValues["espColor_"..key.."_r"] = c.r
            savedValues["espColor_"..key.."_g"] = c.g
            savedValues["espColor_"..key.."_b"] = c.b
            preview.BackgroundColor3 = Color3.fromRGB(c.r, c.g, c.b)
            refreshEspColors()
        end)
    end

    clickBtn.MouseButton1Click:Connect(function()
        dropdown.Visible = not dropdown.Visible
        arrow.Text = dropdown.Visible and "▼" or "▶"
    end)
end

mkLabel(VisualsPage,"ESP COLORS")
mkColorPicker(VisualsPage, "ESP Color", "esp")
mkColorPicker(VisualsPage, "Box Color", "box")
mkColorPicker(VisualsPage, "Name Color", "name")
mkColorPicker(VisualsPage, "Distance Color", "dist")
mkColorPicker(VisualsPage, "Skeleton Color", "skel")
mkLabel(VisualsPage,"FOV CIRCLE")
mkNum(VisualsPage,"FOV Circle Size","fovSize",200,function(v)
    local sz = math.clamp(v, 50, 800)
    fovCircle.Size = UDim2.new(0, sz, 0, sz)
        fovCircle.Position = UDim2.new(0.5, -sz/2, 0.5, -sz/2)
end)
mkColorPicker(VisualsPage, "FOV Circle Color", "fov")

mkLabel(VisualsPage,"NAMES")
local nameEspOn=false
nameTags={}
local nameConns={}
local function addNameTag(p)
    if not nameEspOn or p==LP or not p.Character then return end
    if nameTags[p] and nameTags[p].Parent then return end
    local char = p.Character
    local head = char:FindFirstChild("Head")
        or char:FindFirstChild("UpperTorso")
        or char:FindFirstChild("Torso")
        or char:FindFirstChild("HumanoidRootPart")
        or char:FindFirstChildWhichIsA("BasePart")
    if not head then return end
    local bg=Instance.new("BillboardGui")
    bg.Size=UDim2.new(0,200,0,30)
    bg.StudsOffset=Vector3.new(0,3,0)
    bg.AlwaysOnTop=true
    bg.Adornee=head
    bg.Parent=head
    local lbl=Instance.new("TextLabel")
    lbl.Size=UDim2.new(1,0,1,0)
    lbl.BackgroundTransparency=1
    lbl.Text=p.Name
    lbl.TextColor3=rgbC(espColors.name)
    lbl.TextStrokeTransparency=0
    lbl.Font=Enum.Font.GothamBold
    lbl.TextSize=14
    lbl.Parent=bg
    nameTags[p]=bg
end
mkTog(VisualsPage,"Name ESP",function(on)
    nameEspOn=on
    if on then
        for _,p in pairs(P:GetPlayers()) do addNameTag(p) end
        for _,p in pairs(P:GetPlayers()) do
            if p~=LP then
                local c=p.CharacterAdded:Connect(function()
                    task.wait(0.5)
                    if nameTags[p] then nameTags[p]:Destroy() nameTags[p]=nil end
                    addNameTag(p)
                end)
                table.insert(nameConns,c)
            end
        end
        local newConn=P.PlayerAdded:Connect(function(p)
            local c=p.CharacterAdded:Connect(function()
                task.wait(0.5) addNameTag(p)
            end)
            table.insert(nameConns,c)
        end)
        table.insert(nameConns,newConn)
    else
        for _,c in pairs(nameConns) do c:Disconnect() end
        nameConns={}
        for _,bg in pairs(nameTags) do if bg then bg:Destroy() end end
        nameTags={}
    end
end)

local distOn=false
distTags={}
local distConns={}
local function addDistTag(p)
    if not distOn or p==LP or not p.Character then return end
    if distTags[p] and distTags[p].gui and distTags[p].gui.Parent then return end
    local char = p.Character
    local head = char:FindFirstChild("Head")
        or char:FindFirstChild("UpperTorso")
        or char:FindFirstChild("Torso")
        or char:FindFirstChild("HumanoidRootPart")
        or char:FindFirstChildWhichIsA("BasePart")
    if not head then return end
    local bg=Instance.new("BillboardGui")
    bg.Size=UDim2.new(0,150,0,20)
    bg.StudsOffset=Vector3.new(0,4,0)
    bg.AlwaysOnTop=true
    bg.Adornee=head
    bg.Parent=head
    local lbl=Instance.new("TextLabel")
    lbl.Size=UDim2.new(1,0,1,0)
    lbl.BackgroundTransparency=1
    lbl.Text="0 studs"
    lbl.TextColor3=rgbC(espColors.dist)
    lbl.TextStrokeTransparency=0
    lbl.Font=Enum.Font.GothamBold
    lbl.TextSize=12
    lbl.Parent=bg
    distTags[p]={gui=bg,label=lbl}
end
task.spawn(function()
    while true do
        if distOn then
            local myHrp=LP.Character and LP.Character:FindFirstChild("HumanoidRootPart")
            if myHrp then
                for p,data in pairs(distTags) do
                    if data.gui and data.gui.Parent and p.Character then
                        local tHrp = p.Character:FindFirstChild("HumanoidRootPart") or p.Character:FindFirstChild("UpperTorso") or p.Character:FindFirstChild("Torso") or p.Character:FindFirstChildWhichIsA("BasePart")
                        if tHrp then
                            local d=math.floor((myHrp.Position-tHrp.Position).Magnitude)
                            data.label.Text=d.." studs"
                        end
                    end
                end
            end
        end
        task.wait(0.2)
    end
end)
mkTog(VisualsPage,"Distance ESP",function(on)
    distOn=on
    if on then
        for _,p in pairs(P:GetPlayers()) do addDistTag(p) end
        for _,p in pairs(P:GetPlayers()) do
            if p~=LP then
                local c=p.CharacterAdded:Connect(function()
                    task.wait(0.5)
                    if distTags[p] and distTags[p].gui then distTags[p].gui:Destroy() end
                    distTags[p]=nil
                    addDistTag(p)
                end)
                table.insert(distConns,c)
            end
        end
        local newConn=P.PlayerAdded:Connect(function(p)
            local c=p.CharacterAdded:Connect(function()
                task.wait(0.5) addDistTag(p)
            end)
            table.insert(distConns,c)
        end)
        table.insert(distConns,newConn)
    else
        for _,c in pairs(distConns) do c:Disconnect() end
        distConns={}
        for _,data in pairs(distTags) do if data.gui then data.gui:Destroy() end end
        distTags={}
    end
end)


mkLabel(VisualsPage,"WAYPOINT")

local waypointPos = nil
local waypoints = {}

local wpInput = mkInp(VisualsPage,"Enter waypoint name...")
local wpListFrame = Instance.new("Frame")
wpListFrame.Size = UDim2.new(1,-6,0,0)
wpListFrame.BackgroundColor3 = Color3.fromRGB(30,30,36)
wpListFrame.BackgroundTransparency = 0.3
wpListFrame.BorderSizePixel = 0
wpListFrame.Visible = false
wpListFrame.Parent = VisualsPage
Instance.new("UICorner",wpListFrame).CornerRadius = UDim.new(0,8)
local wpList = Instance.new("UIListLayout",wpListFrame)
wpList.Padding = UDim.new(0,4)
wpList.SortOrder = Enum.SortOrder.LayoutOrder

local function refreshWpList()
    for _,c in pairs(wpListFrame:GetChildren()) do
        if c:IsA("TextButton") or c:IsA("Frame") then c:Destroy() end
    end
    if #waypoints == 0 then
        wpListFrame.Visible = false
        wpListFrame.Size = UDim2.new(1,-6,0,0)
        return
    end
    wpListFrame.Visible = true
    for i,entry in pairs(waypoints) do
        local row = Instance.new("Frame")
        row.Size = UDim2.new(1,0,0,34)
        row.BackgroundTransparency = 1
        row.LayoutOrder = i
        row.Parent = wpListFrame
        local nameLbl = Instance.new("TextLabel")
        nameLbl.Size = UDim2.new(0.4,0,1,0)
        nameLbl.Position = UDim2.new(0,4,0,0)
        nameLbl.BackgroundTransparency = 1
        nameLbl.Text = entry.name
        nameLbl.TextColor3 = Color3.fromRGB(200,200,200)
        nameLbl.Font = Enum.Font.GothamBold
        nameLbl.TextSize = 12
        nameLbl.TextXAlignment = Enum.TextXAlignment.Left
        nameLbl.TextTruncate = Enum.TextTruncate.AtEnd
        nameLbl.Parent = row
        local tpBtn = Instance.new("TextButton")
        tpBtn.Size = UDim2.new(0.42,0,1,0)
        tpBtn.Position = UDim2.new(0.42,0,0,0)
        tpBtn.BackgroundColor3 = Color3.fromRGB(80,200,120)
        tpBtn.Text = "TP"
        tpBtn.TextColor3 = Color3.fromRGB(255,255,255)
        tpBtn.Font = Enum.Font.GothamBold
        tpBtn.TextSize = 11
        tpBtn.BorderSizePixel = 0
        tpBtn.Parent = row
        Instance.new("UICorner",tpBtn).CornerRadius = UDim.new(0,6)
        tpBtn.MouseButton1Click:Connect(function()
            local ch=LP.Character
            if ch and ch:FindFirstChild("HumanoidRootPart") then
                ch.HumanoidRootPart.CFrame = entry.pos
            end
        end)
        
        local delBtn = Instance.new("TextButton")
        delBtn.Size = UDim2.new(0.14,0,1,0)
        delBtn.Position = UDim2.new(0.86,0,0,0)
        delBtn.BackgroundColor3 = Color3.fromRGB(180,45,45)
        delBtn.Text = "×"
        delBtn.TextColor3 = Color3.fromRGB(255,255,255)
        delBtn.Font = Enum.Font.GothamBold
        delBtn.TextSize = 14
        delBtn.BorderSizePixel = 0
        delBtn.Parent = row
        Instance.new("UICorner",delBtn).CornerRadius = UDim.new(0,6)
        delBtn.MouseButton1Click:Connect(function()
            local removed = waypoints[i]
table.remove(waypoints, i)
if removed and removeMarker then removeMarker(removed) end
            refreshWpList()
        end)
    end
    wpListFrame.Size = UDim2.new(1,-6,0, 8 + #waypoints * 38)
end

mkBtn(VisualsPage,"Save Waypoint",function()
    local name = wpInput.Text
    if not name or name=="" then
        wpInput.Text = "Name required!"
        return
    end
    local ch = LP.Character
    if ch and ch:FindFirstChild("HumanoidRootPart") then
        local entry = {name=name, pos=ch.HumanoidRootPart.CFrame}
table.insert(waypoints, entry)
if createMarker then createMarker(entry) end
        wpInput.Text = ""
        refreshWpList()
        notify("Waypoint saved: "..name)
    end
end)

mkBtn(VisualsPage,"Show/Hide Waypoints",function()
    wpListFrame.Visible = not wpListFrame.Visible
    if wpListFrame.Visible then refreshWpList() end
end)


-- Forward declare markers
function createMarker(entry) end
_G.richieVisualsCleanup = function()
    for _, c in pairs(espConns) do pcall(function() c:Disconnect() end) end
    for _, hl in pairs(espH) do if hl then pcall(function() hl:Destroy() end) end end
    for _, c in pairs(boxConns) do pcall(function() c:Disconnect() end) end
    for _, bg in pairs(boxGuis) do if bg then pcall(function() bg:Destroy() end) end end
    for _, c in pairs(healthConns) do pcall(function() c:Disconnect() end) end
    for _, d in pairs(healthTags) do
        if d.gui then pcall(function() d.gui:Destroy() end) end
        if d.conn then pcall(function() d.conn:Disconnect() end) end
    end
    for _, c in pairs(nameConns) do pcall(function() c:Disconnect() end) end
    for _, bg in pairs(nameTags) do if bg then pcall(function() bg:Destroy() end) end end
    for _, c in pairs(distConns) do pcall(function() c:Disconnect() end) end
    for _, d in pairs(distTags) do if d.gui then pcall(function() d.gui:Destroy() end) end end
    for _, c in pairs(skeletonConns) do pcall(function() c:Disconnect() end) end
    for _, data in pairs(skeletonData) do
        if data and data.lines then
            for _, line in pairs(data.lines) do pcall(function() line:Remove() end) end
        end
    end
    for entry, m in pairs(waypointMarkers) do
        if m.billboard then pcall(function() m.billboard:Destroy() end) end
        if m.sphere then pcall(function() m.sphere:Destroy() end) end
    end
    pcall(function() aimFovGui:Destroy() end)
    pcall(function() fovCircleGui:Destroy() end)
end

function removeMarker(entry) end
-- Floating Waypoint Markers
waypointMarkers = {}

function createMarker(entry)
    local billboard = Instance.new("BillboardGui")
    billboard.Size = UDim2.new(0, 100, 0, 60)
    billboard.AlwaysOnTop = true
    billboard.Adornee = nil
    billboard.Parent = SG

    local container = Instance.new("Frame", billboard)
    container.Size = UDim2.new(1,0,1,0)
    container.BackgroundTransparency = 1

    local dot = Instance.new("Frame", container)
    dot.Size = UDim2.new(0, 10, 0, 10)
    dot.Position = UDim2.new(0.5, -5, 0, 0)
    dot.BackgroundColor3 = Color3.fromRGB(80, 200, 255)
    dot.BorderSizePixel = 0
    dot.ZIndex = 5
    Instance.new("UICorner", dot).CornerRadius = UDim.new(1,0)
    local dotStroke = Instance.new("UIStroke", dot)
    dotStroke.Color = Color3.fromRGB(255,255,255)
    dotStroke.Thickness = 2

    local arrow = Instance.new("TextLabel", container)
    arrow.Size = UDim2.new(0, 40, 0, 30)
    arrow.Position = UDim2.new(0.5, -20, 0, 15)
    arrow.BackgroundTransparency = 1
    arrow.Text = "▼"
    arrow.TextColor3 = Color3.fromRGB(80, 200, 255)
    arrow.TextSize = 30
    arrow.Font = Enum.Font.GothamBold
    arrow.ZIndex = 4
    local arrowStroke = Instance.new("UIStroke", arrow)
    arrowStroke.Color = Color3.fromRGB(255,255,255)
    arrowStroke.Thickness = 1.5
    arrowStroke.Transparency = 0.3

    local distLabel = Instance.new("TextLabel", container)
    distLabel.Size = UDim2.new(1, 0, 0, 20)
    distLabel.Position = UDim2.new(0, 0, 0, 45)
    distLabel.BackgroundTransparency = 1
    distLabel.Text = "0m"
    distLabel.TextColor3 = Color3.fromRGB(255,255,255)
    distLabel.TextStrokeTransparency = 0
    distLabel.Font = Enum.Font.GothamBold
    distLabel.TextSize = 14

    local nameLabel = Instance.new("TextLabel", container)
    nameLabel.Size = UDim2.new(1, 0, 0, 16)
    nameLabel.Position = UDim2.new(0, 0, 0, -18)
    nameLabel.BackgroundTransparency = 1
    nameLabel.Text = entry.name
    nameLabel.TextColor3 = Color3.fromRGB(200, 230, 255)
    nameLabel.TextStrokeTransparency = 0
    nameLabel.Font = Enum.Font.GothamSemibold
    nameLabel.TextSize = 12

    local sphere = Instance.new("Part")
    sphere.Shape = Enum.PartType.Ball
    sphere.Size = Vector3.new(1, 1, 1)
    sphere.Anchored = true
    sphere.CanCollide = false
    sphere.Material = Enum.Material.Neon
    sphere.Color = Color3.fromRGB(80, 200, 255)
    sphere.Transparency = 0.3
    sphere.Position = entry.pos.Position
    sphere.Parent = W

    waypointMarkers[entry] = {
        billboard = billboard,
        arrow = arrow,
        dot = dot,
        distLabel = distLabel,
        nameLabel = nameLabel,
        sphere = sphere
    }
end

function removeMarker(entry)
    local m = waypointMarkers[entry]
    if m then
        if m.billboard then m.billboard:Destroy() end
        if m.sphere then m.sphere:Destroy() end
        waypointMarkers[entry] = nil
    end
end

task.spawn(function()
    while true do
        local myHrp = LP.Character and LP.Character:FindFirstChild("HumanoidRootPart")
        if myHrp then
            for entry, m in pairs(waypointMarkers) do
                if m.billboard and m.billboard.Parent then
                    local pos = entry.pos.Position
                    local dist = (myHrp.Position - pos).Magnitude
                    local meters = math.floor(dist / 3.28)

                    m.billboard.Adornee = m.sphere
                    m.distLabel.Text = meters.."m"

                    local scale = math.clamp(meters / 100, 0.7, 2.5)
                    m.billboard.Size = UDim2.new(0, 100 * scale, 0, 60 * scale)
                    m.arrow.TextSize = math.clamp(30 * scale, 20, 60)
                    m.distLabel.TextSize = math.clamp(14 * scale, 10, 24)

                    if meters < 3 then
                        m.billboard.Enabled = false
                    else
                        m.billboard.Enabled = true
                    end
                end
            end
        end
        task.wait(0.05)
    end
end)
end

-- ============ WORLD ============
do
mkLabel(WorldPage,"LIGHTING")
mkTog(WorldPage,"Fullbright",function(on)
    if on then
        L.Ambient=Color3.fromRGB(180,180,180)
        L.OutdoorAmbient=Color3.fromRGB(180,180,180)
        L.Brightness=2
        L.FogEnd=1e6
    else
        L.Ambient=origAmb
        L.OutdoorAmbient=origOutdoor
        L.Brightness=origBright
        L.FogEnd=origFogEnd
    end
end)

mkTog(WorldPage,"No Fog",function(on)
    if on then
        L.FogStart=0
        L.FogEnd=1e9
        local atm=L:FindFirstChildOfClass("Atmosphere")
        if atm then
            atm.Density=0
            atm.Haze=0
            atm.Glare=0
        end
    else
        L.FogStart=origFogStart
        L.FogEnd=origFogEnd
    end
end)

mkNum(WorldPage,"Time of Day","time",14,function(v) L.ClockTime=v end)

mkLabel(WorldPage,"SERVER")
mkBtn(WorldPage,"Server Hop",function()
    local TS=game:GetService("TeleportService")
    local HS=game:GetService("HttpService")
    local placeId=game.PlaceId
    local url="https://games.roblox.com/v1/games/"..placeId.."/servers/Public?sortOrder=Asc&limit=100"
    local ok,response=pcall(function() return HS:JSONDecode(game:HttpGet(url)) end)
    if not ok or not response or not response.data then
        notify("Server hop failed")
        return
    end
    local servers={}
    for _,s in pairs(response.data) do
        if s.playing < s.maxPlayers and s.id ~= game.JobId then
            table.insert(servers, s.id)
        end
    end
    if #servers == 0 then
        notify("No servers found")
        return
    end
    local picked=servers[math.random(1,#servers)]
    notify("Hopping server...")
    task.wait(0.5)
    pcall(function() TS:TeleportToPlaceInstance(placeId, picked, LP) end)
end)

mkLabel(WorldPage,"PLAYER NOTIFIER")
local notifierAllOn = false
local trackedIds = {}

mkTog(WorldPage,"Notifier (All Players)",function(on)
    notifierAllOn = on
    notify("Player Notifier: "..(on and "ON" or "OFF"))
end)

P.PlayerAdded:Connect(function(p)
    if p == LP then return end
    task.wait(0.3)
    if notifierAllOn then
        notifyGreen(p.Name.." has joined the server")
    end
    if trackedIds[p.UserId] then
        trackedIds[p.UserId] = nil
        notifyGreen(p.Name.." has joined back")
    end
end)

P.PlayerRemoving:Connect(function(p)
    if p == LP then return end
    local isTracked = false
    if _G.richieTarget == p then isTracked = true end
    local ms = _G.richieMultiSelected
    if ms and ms[p] then isTracked = true end
    if isTracked then
        trackedIds[p.UserId] = true
        notifyRed(p.Name.." has left the server")
    elseif notifierAllOn then
        notifyRed(p.Name.." has left the server")
    end
end)


mkLabel(WorldPage,"AUTO-REJOIN")
local arSavedJob = nil
local arSavedPlace = nil
local arOn = false

mkTog(WorldPage,"Auto-Rejoin on Disconnect",function(on)
    arOn = on
    if on then
        arSavedJob = game.JobId
        arSavedPlace = game.PlaceId
        pcall(function()
            if queue_on_teleport then
                queue_on_teleport([[
                    task.wait(3)
                    local TS = game:GetService("TeleportService")
                    local job = "]]..arSavedJob..[["
                    if job and job ~= "" then
                        TS:TeleportToPlaceInstance(]]..arSavedPlace..[[, job, game:GetService("Players").LocalPlayer)
                    end
                ]])
            end
        end)
        notify("Auto-Rejoin: ON")
    else
        notify("Auto-Rejoin: OFF")
    end
end)

mkBtn(WorldPage,"Rejoin Same Server",function()
    local job = arSavedJob or game.JobId
    local place = arSavedPlace or game.PlaceId
    notify("Rejoining same server...")
    task.wait(0.5)
    pcall(function()
        game:GetService("TeleportService"):TeleportToPlaceInstance(place, job, LP)
    end)
end)

mkLabel(WorldPage,"PHYSICS")
mkNum(WorldPage,"Gravity","grav",196,function(v) W.Gravity=v end)

mkTog(WorldPage,"Low Gravity",function(on)
    if on then
        W.Gravity=50
    else
        W.Gravity=origGrav
    end
end)

mkTog(WorldPage,"Anti-Kick",function(on)
    if on then
        _G.richieAntiKick=LP.OnTeleport:Connect(function() end)
        local oldKick
        pcall(function()
            oldKick=hookfunction(LP.Kick, function(self, reason)
                notify("Kick blocked: "..tostring(reason))
            end)
        end)
        if not oldKick then
            for _,v in pairs(game:GetService("ReplicatedStorage"):GetDescendants()) do
                if v:IsA("RemoteEvent") and v.Name:lower():find("kick") then
                    pcall(function() v.OnClientEvent:Connect(function() end) end)
                end
            end
        end
    else
        if _G.richieAntiKick then _G.richieAntiKick:Disconnect() _G.richieAntiKick=nil end
    end
end)

mkLabel(WorldPage,"EFFECTS")
mkTog(WorldPage,"Anti-Fling",function(on)
    if on then
        _G.richieAntiFling=R.Heartbeat:Connect(function()
            local ch=LP.Character
            if ch and ch:FindFirstChild("HumanoidRootPart") then
                local v=ch.HumanoidRootPart.Velocity
                if v.Magnitude > 500 then
                    ch.HumanoidRootPart.Velocity=Vector3.new(0,0,0)
                end
            end
        end)
    else
        if _G.richieAntiFling then _G.richieAntiFling:Disconnect() _G.richieAntiFling=nil end
    end
end)

mkTog(WorldPage,"Freeze Self",function(on)
    if on then
        _G.richieFreeze=R.Heartbeat:Connect(function()
            local ch=LP.Character
            if ch and ch:FindFirstChild("HumanoidRootPart") then
                ch.HumanoidRootPart.Anchored=true
            end
        end)
    else
        if _G.richieFreeze then _G.richieFreeze:Disconnect() _G.richieFreeze=nil end
        local ch=LP.Character
        if ch and ch:FindFirstChild("HumanoidRootPart") then
            ch.HumanoidRootPart.Anchored=false
        end
    end
end)
end
do
mkLabel(WorldPage,"WEATHER (Can Cause lag and fps drops)")

local weatherInstances = {}
local weatherConn = nil
local weatherParts = {}
local weatherPartSpeed = 0
local weatherPartSway = false
local thunderActive = false
local rainSound = nil

local function track(inst)
    table.insert(weatherInstances, inst)
    return inst
end

local function spawnLightningBolt(basePos)
    local boltFolder = Instance.new("Folder")
    boltFolder.Name = "RichieBolt"
    boltFolder.Parent = W
    track(boltFolder)
    local startPos = basePos + Vector3.new(math.random(-120,120), 260, math.random(-120,120))
    local endPos = basePos + Vector3.new(math.random(-40,40), 25, math.random(-40,40))
    local segments = 14
    local points = {}
    for i = 0, segments do
        local t = i / segments
        local pos = startPos:Lerp(endPos, t)
        if i > 0 and i < segments then
            pos = pos + Vector3.new(math.random(-8,8), 0, math.random(-8,8))
        end
        table.insert(points, pos)
    end
    for i = 1, #points - 1 do
        local p1 = points[i]
        local p2 = points[i+1]
        local mid = (p1 + p2) / 2
        local dist = (p2 - p1).Magnitude
        local seg = Instance.new("Part")
        seg.Anchored = true
        seg.CanCollide = false
        seg.CanQuery = false
        seg.Material = Enum.Material.Neon
        seg.Color = Color3.fromRGB(230,230,255)
        seg.Size = Vector3.new(0.6, 0.6, dist)
        seg.CFrame = CFrame.lookAt(mid, p2)
        seg.Parent = boltFolder
    end
    task.delay(0.25, function()
        if boltFolder and boltFolder.Parent then boltFolder:Destroy() end
    end)
end

local function stopWeather()
    thunderActive = false
    if weatherConn then weatherConn:Disconnect() weatherConn=nil end
    for _, inst in pairs(weatherInstances) do
        if inst and inst.Parent then
            pcall(function()
                if inst:IsA("ParticleEmitter") then inst:Clear() end
                inst:Destroy()
            end)
        end
    end
    weatherInstances = {}
    weatherParts = {}
    weatherPartSpeed = 0
    weatherPartSway = false
    if rainSound then rainSound:Stop() rainSound:Destroy() rainSound=nil end
    L.FogStart = origFogStart
    L.FogEnd = origFogEnd
    L.FogColor = Color3.fromRGB(192,192,192)
    L.Brightness = origBright
    local atm = L:FindFirstChildOfClass("Atmosphere")
    if atm then atm.Density = 0.3 atm.Haze = 0 end
end

local function buildRain(hrp, count, isSnow)
    local folder = Instance.new("Folder")
    folder.Name = isSnow and "RichieSnow" or "RichieRain"
    folder.Parent = W
    track(folder)
    local base = hrp.Position
    for i = 1, count do
        local p = Instance.new("Part")
        if isSnow then
            p.Shape = Enum.PartType.Ball
            p.Size = Vector3.new(0.5, 0.5, 0.5)
            p.Color = Color3.fromRGB(255,255,255)
            p.Material = Enum.Material.SmoothPlastic
            p.Transparency = 0.15
        else
            p.Size = Vector3.new(0.15, 0.15, 3)
p.Orientation = Vector3.new(90, 0, 0)
            p.Color = Color3.fromRGB(180,200,255)
            p.Material = Enum.Material.Neon
            p.Transparency = 0.35
        end
        p.Anchored = true
        p.CanCollide = false
        p.CanQuery = false
        p.CanTouch = false
        p.Parent = folder
        p.Position = Vector3.new(
            base.X + math.random(-200,200),
            base.Y + math.random(20,200),
            base.Z + math.random(-200,200)
        )
        table.insert(weatherParts, p)
    end
    weatherPartSpeed = isSnow and 0.6 or 8
    weatherPartSway = isSnow
end

local function startWeather(kind)
    stopWeather()
    if kind == "Clear" then notify("Weather: Clear") return end
    local ch = LP.Character or LP.CharacterAdded:Wait()
    local hrp = ch:WaitForChild("HumanoidRootPart", 5)
    if not hrp then notify("Character not ready") return end

    if kind == "Fog" then
        L.FogColor = Color3.fromRGB(200,200,205)
        L.FogStart = 0
        L.FogEnd = 60
        local atm = L:FindFirstChildOfClass("Atmosphere")
        if atm then atm.Density = 1 atm.Haze = 5 atm.Glare = 0 atm.Color = Color3.fromRGB(200,200,205) end
        notify("Weather: Fog")
        return
    end

    if kind == "Rain" or kind == "Thunder" then
        buildRain(hrp, 250, false)
        rainSound = Instance.new("Sound")
        rainSound.SoundId = "rbxassetid://9064263922"
        rainSound.Volume = 0.6
        rainSound.Looped = true
        rainSound.Parent = SG
        rainSound:Play()
        track(rainSound)
        L.FogColor = Color3.fromRGB(120,130,140)
        L.FogStart = 0
        L.FogEnd = 250

        if kind == "Thunder" then
            L.FogColor = Color3.fromRGB(30,30,40)
            L.FogEnd = 180
            L.Brightness = 0.4
            thunderActive = true
            task.spawn(function()
                while thunderActive do
                    task.wait(math.random(3,7))
                    if not thunderActive then break end
                    local c = LP.Character
                    local h = c and c:FindFirstChild("HumanoidRootPart")
                    if h then spawnLightningBolt(h.Position) end
                    local flash = Instance.new("Frame")
                    flash.Size = UDim2.new(1,0,1,0)
                    flash.BackgroundColor3 = Color3.fromRGB(255,255,255)
                    flash.BackgroundTransparency = 0.15
                    flash.BorderSizePixel = 0
                    flash.ZIndex = 999
                    flash.Parent = SG
                    L.Brightness = 7
                    task.wait(0.06)
                    flash.BackgroundTransparency = 0.5
                    L.Brightness = 2.5
                    task.wait(0.06)
                    flash.BackgroundTransparency = 0.2
                    L.Brightness = 5
                    task.wait(0.05)
                    flash:Destroy()
                    L.Brightness = 0.4
                    local thunder = Instance.new("Sound")
                    thunder.SoundId = "rbxassetid://139968319088532"
                    thunder.Volume = 1
                    thunder.Parent = SG
                    thunder:Play()
                    task.spawn(function()
                        task.wait(6)
                        if thunder then thunder:Destroy() end
                    end)
                end
            end)
        end
        notify("Weather: "..kind)
    elseif kind == "Snow" then
        buildRain(hrp, 320, true)
        L.FogColor = Color3.fromRGB(220,225,235)
        L.FogStart = 0
        L.FogEnd = 300
        notify("Weather: Snow")
    end

    weatherConn = R.Heartbeat:Connect(function()
        local c = LP.Character
        if not c then return end
        local h = c:FindFirstChild("HumanoidRootPart")
        if not h then return end
        local base = h.Position
        local sway = tick()
        for _, p in pairs(weatherParts) do
            if p and p.Parent then
                local np = p.Position - Vector3.new(0, weatherPartSpeed, 0)
                if weatherPartSway then
                    np = np + Vector3.new(math.sin(sway + p.Position.X) * 0.05, 0, math.cos(sway + p.Position.Z) * 0.05)
                end
                if np.Y < base.Y - 20 then
                    np = Vector3.new(
                        base.X + math.random(-200,200),
                        base.Y + 150,
                        base.Z + math.random(-200,200)
                    )
                elseif (np - base).Magnitude > 350 then
                    np = Vector3.new(
                        base.X + math.random(-200,200),
                        base.Y + 150,
                        base.Z + math.random(-200,200)
                    )
                end
                p.Position = np
            end
        end
    end)
end

mkBtn(WorldPage,"Rain",function() startWeather("Rain") end)
mkBtn(WorldPage,"Snow",function() startWeather("Snow") end)
mkBtn(WorldPage,"Fog",function() startWeather("Fog") end)
mkBtn(WorldPage,"Thunder",function() startWeather("Thunder") end)
mkBtn(WorldPage,"Clear Weather",function() startWeather("Clear") end)
_G.richieWeatherCleanup = stopWeather

end

do
mkLabel(WorldPage,"SKYBOX (Atmosphere)")

local origAtmData = nil
local curSkyBtn = nil

local skyOptions = {
    {name="Day Blue", r=100, g=170, b=255, density=0.3, time=14},
    {name="Sunset Orange", r=255, g=140, b=80, density=0.5, time=17.5},
    {name="Sunrise Pink", r=255, g=180, b=200, density=0.5, time=6.5},
    {name="Night Dark", r=15, g=20, b=45, density=0.6, time=0},
    {name="Stormy Grey", r=80, g=80, b=90, density=0.8, time=14},
    {name="Deep Purple", r=60, g=30, b=100, density=0.6, time=20},
    {name="Alien Green", r=100, g=200, b=150, density=0.5, time=14},
    {name="Golden", r=255, g=210, b=100, density=0.4, time=17},
}

local function saveOrigAtm()
    if origAtmData then return end
    local atm = L:FindFirstChildOfClass("Atmosphere")
    if atm then
        origAtmData = {
            existed = true,
            Color = atm.Color,
            Decay = atm.Decay,
            Density = atm.Density,
            Haze = atm.Haze,
            Glare = atm.Glare,
            Offset = atm.Offset
        }
    else
        origAtmData = { existed = false }
    end
end

local function applySky(opt)
    saveOrigAtm()
    local atm = L:FindFirstChildOfClass("Atmosphere")
    if not atm then atm = Instance.new("Atmosphere", L) end
    atm.Color = Color3.fromRGB(opt.r, opt.g, opt.b)
    atm.Decay = Color3.fromRGB(math.floor(opt.r*0.5), math.floor(opt.g*0.5), math.floor(opt.b*0.5))
    atm.Density = opt.density
    atm.Haze = 2
    atm.Glare = 1
    L.ColorShift_Top = Color3.fromRGB(opt.r, opt.g, opt.b)
    L.ColorShift_Bottom = Color3.fromRGB(math.floor(opt.r*0.4), math.floor(opt.g*0.4), math.floor(opt.b*0.4))
    L.ClockTime = opt.time
    L.Brightness = 2
    notify("Sky: "..opt.name)
end

local function restoreDefaultSky()
    if origAtmData then
        local atm = L:FindFirstChildOfClass("Atmosphere")
        if origAtmData.existed then
            if atm then
                atm.Color = origAtmData.Color
                atm.Decay = origAtmData.Decay
                atm.Density = origAtmData.Density
                atm.Haze = origAtmData.Haze
                atm.Glare = origAtmData.Glare
                atm.Offset = origAtmData.Offset
            end
        else
            if atm then atm:Destroy() end
        end
    end
    L.ColorShift_Top = Color3.fromRGB(0,0,0)
    L.ColorShift_Bottom = Color3.fromRGB(0,0,0)
    L.Brightness = origBright
    L.ClockTime = 14
    notify("Skybox: Default")
end

for _, opt in ipairs(skyOptions) do
    mkBtn(WorldPage, opt.name, function() applySky(opt) end)
end
mkBtn(WorldPage, "Default Sky", restoreDefaultSky)
local customSkyInput = mkInp(WorldPage, "Enter custom skybox asset ID...")
customSkyInput.TextEditable = true
customSkyInput:GetPropertyChangedSignal("Text"):Connect(function()
        local raw = customSkyInput.Text
    local digits = raw:match("(%d+)")
    if digits and digits ~= raw then
        local pos = customSkyInput.CursorPosition
        customSkyInput.Text = digits
        customSkyInput.CursorPosition = math.min(pos, #digits + 1)
    elseif digits == nil and raw ~= "" then
        customSkyInput.Text = ""
    end
end)

local origSkyTexture = nil
local function saveSkyTexture()
    if origSkyTexture then return end
    local s = L:FindFirstChildOfClass("Sky")
    if s then
        origSkyTexture = {
            existed = true,
            Bk = s.SkyboxBk, Dn = s.SkyboxDn, Ft = s.SkyboxFt,
            Lf = s.SkyboxLf, Rt = s.SkyboxRt, Up = s.SkyboxUp
        }
    else
        origSkyTexture = { existed = false }
    end
end


mkBtn(WorldPage, "Apply Custom Skybox ID", function()
    local id = customSkyInput.Text
    if not id or id == "" then
        notifyRed("Code Is Invalid!")
        return
    end
   
    local fullId = "rbxassetid://"..id
    saveSkyTexture()
    local sky = L:FindFirstChildOfClass("Sky")
    if not sky then sky = Instance.new("Sky", L) end
    sky.SkyboxBk = fullId
    sky.SkyboxDn = fullId
    sky.SkyboxFt = fullId
    sky.SkyboxLf = fullId
    sky.SkyboxRt = fullId
    sky.SkyboxUp = fullId
    notifyGreen("Changed To "..id)
end)
-- END OF OLD BLOCK, DELETE EVERYTHING BELOW UNTIL THE NEXT LINE
_G.richieSkyCleanup = restoreDefaultSky

end


-- ============ WORLD — MISC ============
do
mkLabel(WorldPage,"MISC")

local antiAfkConn = nil
local antiAfkOn = false
local function startAntiAfk()
    if antiAfkConn then antiAfkConn:Disconnect() antiAfkConn=nil end
    local vu=game:GetService("VirtualUser")
    antiAfkConn = LP.Idled:Connect(function()
        if not antiAfkOn then return end
        vu:Button2Down(Vector2.new(0,0), W.CurrentCamera.CFrame)
        task.wait(1)
        vu:Button2Up(Vector2.new(0,0), W.CurrentCamera.CFrame)
    end)
end

mkTog(WorldPage,"Anti-AFK",function(on)
    antiAfkOn = on
    if on then
        startAntiAfk()
        notify("Anti-AFK: ON")
    else
        if antiAfkConn then antiAfkConn:Disconnect() antiAfkConn=nil end
        notify("Anti-AFK: OFF")
    end
end)

local fpsUnlockOn = false
local maxFpsValue = 240
local function applyFps()
    if fpsUnlockOn then
        pcall(function() setfpscap(maxFpsValue) end)
    else
        pcall(function() setfpscap(60) end)
    end
end

mkTog(WorldPage,"FPS Unlocker",function(on)
    fpsUnlockOn = on
    applyFps()
    notify("FPS Unlocker: "..(on and "ON" or "OFF"))
end)

mkNum(WorldPage,"Max FPS","maxFps",240,function(v)
    maxFpsValue = math.clamp(math.floor(tonumber(v) or 240), 30, 999)
    if fpsUnlockOn then applyFps() end
end)
end
-- ============ CONFIG ============
do
mkLabel(ConfigPage,"SAVE / LOAD")
local CONFIG_FOLDER="richiehub_configs"
local CONFIG_INDEX=CONFIG_FOLDER.."/index.txt"
pcall(function()
    if not isfolder(CONFIG_FOLDER) then makefolder(CONFIG_FOLDER) end
end)

local function getConfigList()
    local list={}
    pcall(function()
        if isfile(CONFIG_INDEX) then
            local content=readfile(CONFIG_INDEX)
            for name in content:gmatch("[^\n]+") do
                table.insert(list, name)
            end
        end
    end)
    return list
end

local function saveConfigList(list)
    pcall(function()
        writefile(CONFIG_INDEX, table.concat(list, "\n"))
    end)
end

local saveInp=mkInp(ConfigPage,"Enter config name...")

mkBtn(ConfigPage,"Save Config",function()
    local name=saveInp.Text
    if not name or name=="" then
        saveInp.Text="Name required!"
        return
    end
    local data={}
    for k,v in pairs(savedValues) do data[k]=v end
    local jsonStr="{"
    local first=true
    for k,v in pairs(data) do
        if not first then jsonStr=jsonStr.."," end
        jsonStr=jsonStr..'"'..k..'":'..tostring(v)
        first=false
    end
    jsonStr=jsonStr.."}"
    pcall(function()
        writefile(CONFIG_FOLDER.."/"..name..".cfg", jsonStr)
        local list=getConfigList()
        local found=false
        for _,n in pairs(list) do if n==name then found=true break end end
        if not found then
            table.insert(list, name)
            saveConfigList(list)
        end
    end)
    saveInp.Text="Saved: "..name
end)

local savedListFrame=Instance.new("Frame")
savedListFrame.Size=UDim2.new(1,-6,0,0)
savedListFrame.BackgroundColor3=Color3.fromRGB(30,30,36)
savedListFrame.BackgroundTransparency=0.3
savedListFrame.BorderSizePixel=0
savedListFrame.Visible=false
savedListFrame.Parent=ConfigPage
Instance.new("UICorner",savedListFrame).CornerRadius=UDim.new(0,8)
local savedListLayout=Instance.new("UIListLayout",savedListFrame)
savedListLayout.Padding=UDim.new(0,4)
savedListLayout.SortOrder=Enum.SortOrder.LayoutOrder

local function refreshSavedList()
    for _,c in pairs(savedListFrame:GetChildren()) do
        if c:IsA("TextButton") or c:IsA("Frame") then c:Destroy() end
    end
    local list=getConfigList()
    if #list==0 then
        savedListFrame.Visible=false
        savedListFrame.Size=UDim2.new(1,-6,0,0)
        return
    end
    savedListFrame.Visible=true
    for i,name in pairs(list) do
        local row=Instance.new("Frame")
        row.Size=UDim2.new(1,0,0,34)
        row.BackgroundTransparency=1
        row.LayoutOrder=i
        row.Parent=savedListFrame
        local nameLbl=Instance.new("TextLabel")
        nameLbl.Size=UDim2.new(0.4,0,1,0)
        nameLbl.Position=UDim2.new(0,4,0,0)
        nameLbl.BackgroundTransparency=1
        nameLbl.Text=name
        nameLbl.TextColor3=Color3.fromRGB(200,200,200)
        nameLbl.Font=Enum.Font.GothamBold
        nameLbl.TextSize=12
        nameLbl.TextXAlignment=Enum.TextXAlignment.Left
        nameLbl.Parent=row
        local loadBtn=Instance.new("TextButton")
        loadBtn.Size=UDim2.new(0.28,0,1,0)
        loadBtn.Position=UDim2.new(0.42,0,0,0)
        loadBtn.BackgroundColor3=Color3.fromRGB(80,200,120)
        loadBtn.Text="Load"
        loadBtn.TextColor3=Color3.fromRGB(255,255,255)
        loadBtn.Font=Enum.Font.GothamBold
        loadBtn.TextSize=11
        loadBtn.BorderSizePixel=0
        loadBtn.Parent=row
        Instance.new("UICorner",loadBtn).CornerRadius=UDim.new(0,6)
        loadBtn.MouseButton1Click:Connect(function()
            local path=CONFIG_FOLDER.."/"..name..".cfg"
            pcall(function()
                if isfile(path) then
                    local content=readfile(path)
                    for k,v in content:gmatch('"([^"]+)":([%-%d%.]+)') do
                        local num=tonumber(v)
                        if num then savedValues[k]=num end
                    end
                    local ch=LP.Character
                    if ch and ch:FindFirstChild("Humanoid") then
                        local hm=ch.Humanoid
                        if savedValues["speed"] then hm.WalkSpeed=savedValues["speed"] end
                        if savedValues["jump"] then
                            hm.UseJumpPower=true
                            hm.JumpPower=savedValues["jump"]
                        end
                    end
                    if savedValues["fov"] then C.FieldOfView=savedValues["fov"] end
                    if savedValues["grav"] then W.Gravity=savedValues["grav"] end
                end
            end)
        end)
        local delBtn=Instance.new("TextButton")
        delBtn.Size=UDim2.new(0.28,0,1,0)
        delBtn.Position=UDim2.new(0.72,0,0,0)
        delBtn.BackgroundColor3=Color3.fromRGB(180,45,45)
        delBtn.Text="Delete"
        delBtn.TextColor3=Color3.fromRGB(255,255,255)
        delBtn.Font=Enum.Font.GothamBold
        delBtn.TextSize=11
        delBtn.BorderSizePixel=0
        delBtn.Parent=row
        Instance.new("UICorner",delBtn).CornerRadius=UDim.new(0,6)
        delBtn.MouseButton1Click:Connect(function()
            pcall(function() delfile(CONFIG_FOLDER.."/"..name..".cfg") end)
            local newList={}
            for _,n in pairs(getConfigList()) do
                if n~=name then table.insert(newList, n) end
            end
            saveConfigList(newList)
            refreshSavedList()
        end)
    end
    savedListFrame.Size=UDim2.new(1,-6,0, 8 + #list * 38)
end

mkBtn(ConfigPage,"Show Configs",function()
    savedListFrame.Visible = not savedListFrame.Visible
    if savedListFrame.Visible then refreshSavedList() end
end)
end
-- ============ TARGET TAB ============
do
mkLabel(TargetPage,"TARGET PLAYER")
local targetInput=mkInp(TargetPage,"Enter target username...")
local targetResolved=Instance.new("TextLabel")
targetResolved.Size=UDim2.new(1,-6,0,20)
targetResolved.BackgroundTransparency=1
targetResolved.Text=""
targetResolved.TextColor3=Color3.fromRGB(80,200,120)
targetResolved.Font=Enum.Font.GothamBold
targetResolved.TextSize=12
targetResolved.TextXAlignment=Enum.TextXAlignment.Left
targetResolved.Parent=TargetPage


-- ============ PLAYERS LIST ============
local playersListOpen = false
local playersListFrame = Instance.new("Frame")
playersListFrame.Size = UDim2.new(1,-6,0,36)
playersListFrame.BackgroundColor3 = Color3.fromRGB(30,30,36)
playersListFrame.BackgroundTransparency = 0.2
playersListFrame.BorderSizePixel = 0
playersListFrame.Parent = TargetPage
Instance.new("UICorner",playersListFrame).CornerRadius = UDim.new(0,8)

local plToggleBtn = Instance.new("TextButton")
plToggleBtn.Size = UDim2.new(1,0,1,0)
plToggleBtn.BackgroundTransparency = 1
plToggleBtn.Text = ""
plToggleBtn.Parent = playersListFrame

local plHeader = Instance.new("TextLabel")
plHeader.Size = UDim2.new(1,-40,1,0)
plHeader.Position = UDim2.new(0,14,0,0)
plHeader.BackgroundTransparency = 1
plHeader.Text = "Show Players / عرض قائمة اللاعبين"
plHeader.TextColor3 = Color3.fromRGB(220,220,220)
plHeader.Font = Enum.Font.GothamBold
plHeader.TextSize = 13
plHeader.TextXAlignment = Enum.TextXAlignment.Left
plHeader.Parent = playersListFrame

local plArrow = Instance.new("TextLabel")
plArrow.Size = UDim2.new(0,20,1,0)
plArrow.Position = UDim2.new(1,-26,0,0)
plArrow.BackgroundTransparency = 1
plArrow.Text = "▼"
plArrow.TextColor3 = Color3.fromRGB(80,200,120)
plArrow.Font = Enum.Font.GothamBold
plArrow.TextSize = 14
plArrow.Parent = playersListFrame

local playersContainer = Instance.new("Frame")
playersContainer.Size = UDim2.new(1,-6,0,0)
playersContainer.BackgroundColor3 = Color3.fromRGB(25,25,30)
playersContainer.BackgroundTransparency = 0.3
playersContainer.BorderSizePixel = 0
playersContainer.Visible = false
playersContainer.Parent = TargetPage
Instance.new("UICorner",playersContainer).CornerRadius = UDim.new(0,8)
local pcList = Instance.new("UIListLayout",playersContainer)
pcList.Padding = UDim.new(0,4)
pcList.SortOrder = Enum.SortOrder.LayoutOrder

local function refreshPlayersList()
    for _,c in pairs(playersContainer:GetChildren()) do
        if c:IsA("Frame") then c:Destroy() end
    end

    local players = {}
    for _,p in pairs(P:GetPlayers()) do
        if p ~= LP then table.insert(players, p) end
    end

    if #players == 0 then
        local empty = Instance.new("Frame")
        empty.Size = UDim2.new(1,0,0,40)
        empty.BackgroundTransparency = 1
        empty.LayoutOrder = 1
        empty.Parent = playersContainer
        local lbl = Instance.new("TextLabel")
        lbl.Size = UDim2.new(1,0,1,0)
        lbl.BackgroundTransparency = 1
        lbl.Text = "No players"
        lbl.TextColor3 = Color3.fromRGB(150,150,150)
        lbl.Font = Enum.Font.Gotham
        lbl.TextSize = 13
        lbl.Parent = empty
        playersContainer.Size = UDim2.new(1,-6,0, 8 + 40)
        return
    end

    for i, p in ipairs(players) do
        local row = Instance.new("Frame")
        row.Size = UDim2.new(1,0,0,50)
        row.BackgroundColor3 = Color3.fromRGB(35,35,42)
        row.BackgroundTransparency = 0.4
        row.BorderSizePixel = 0
        row.LayoutOrder = i
        row.Parent = playersContainer
        Instance.new("UICorner",row).CornerRadius = UDim.new(0,6)

        local avatar = Instance.new("ImageLabel")
        avatar.Size = UDim2.new(0, 38, 0, 38)
        avatar.Position = UDim2.new(0, 6, 0.5, -19)
        avatar.BackgroundColor3 = Color3.fromRGB(60,60,70)
        avatar.BorderSizePixel = 0
        avatar.Image = ""
        avatar.Parent = row
        Instance.new("UICorner",avatar).CornerRadius = UDim.new(1,0)

        pcall(function()
            local thumb = P:GetUserThumbnailAsync(p.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
            avatar.Image = thumb
        end)

        local nameLbl = Instance.new("TextLabel")
        nameLbl.Size = UDim2.new(1,-60,0,22)
        nameLbl.Position = UDim2.new(0, 52, 0, 4)
        nameLbl.BackgroundTransparency = 1
        nameLbl.Text = p.DisplayName
        nameLbl.TextColor3 = Color3.fromRGB(240,240,240)
        nameLbl.Font = Enum.Font.GothamBold
        nameLbl.TextSize = 13
        nameLbl.TextXAlignment = Enum.TextXAlignment.Left
        nameLbl.TextTruncate = Enum.TextTruncate.AtEnd
        nameLbl.Parent = row

        local userLbl = Instance.new("TextLabel")
        userLbl.Size = UDim2.new(1,-60,0,16)
        userLbl.Position = UDim2.new(0, 52, 0, 26)
        userLbl.BackgroundTransparency = 1
        userLbl.Text = "@"..p.Name
        userLbl.TextColor3 = Color3.fromRGB(140,140,150)
        userLbl.Font = Enum.Font.Gotham
        userLbl.TextSize = 11
        userLbl.TextXAlignment = Enum.TextXAlignment.Left
        userLbl.TextTruncate = Enum.TextTruncate.AtEnd
        userLbl.Parent = row

        local clickBtn = Instance.new("TextButton")
        clickBtn.Size = UDim2.new(1,0,1,0)
        clickBtn.BackgroundTransparency = 1
        clickBtn.Text = ""
        clickBtn.Parent = row
        clickBtn.MouseButton1Click:Connect(function()
            targetInput.Text = p.Name
            targetResolved.Text = "✓ "..p.Name
            targetResolved.TextColor3 = Color3.fromRGB(80,200,120)
            _G.richieTarget = p
            _G.richieTargetName = p.Name
            notify("Target: "..p.Name)
        end)
    end
    playersContainer.Size = UDim2.new(1,-6,0, 8 + #players * 54)
end

plToggleBtn.MouseButton1Click:Connect(function()
    playersListOpen = not playersListOpen
    playersContainer.Visible = playersListOpen
    plArrow.Text = playersListOpen and "▲" or "▼"
    if playersListOpen then refreshPlayersList() end
end)

task.spawn(function()
    while true do
        task.wait(2)
        if playersListOpen then refreshPlayersList() end
    end
end)

local function resolveTarget(q)
    if not q or q=="" then return nil,"" end
    q=q:lower()
    for _,p in pairs(P:GetPlayers()) do
        if p~=LP and p.Name:lower()==q then return p,p.Name end
    end
    local m={}
    for _,p in pairs(P:GetPlayers()) do
        if p~=LP and p.Name:lower():sub(1,#q)==q then table.insert(m,p) end
    end
    if #m==1 then return m[1],m[1].Name end
    if #m==0 then return nil,"" end
    return nil,"user not found."
end

local lastUserEdit=0
local lastResolved=""

targetInput:GetPropertyChangedSignal("Text"):Connect(function()
    local text=targetInput.Text
    if text=="" then
        _G.richieTarget=nil
        _G.richieTargetName=""
        targetResolved.Text=""
        lastResolved=""
        return
    end
    if text==lastResolved then return end
    lastUserEdit=tick()
    task.delay(0.6,function()
        if tick()-lastUserEdit<0.5 then return end
        local p,result=resolveTarget(targetInput.Text)
        if p then
            _G.richieTarget=p
            _G.richieTargetName=p.Name
            targetResolved.Text="✓ "..p.Name
            targetResolved.TextColor3=Color3.fromRGB(80,200,120)
            if targetInput.Text~=p.Name then
                lastResolved=p.Name
                targetInput.Text=p.Name
                targetInput.CursorPosition=#p.Name+1
            end
        elseif result=="user not found." then
            _G.richieTarget=nil
            _G.richieTargetName=""
            targetResolved.Text="user not found."
            targetResolved.TextColor3=Color3.fromRGB(255,80,80)
        else
            _G.richieTarget=nil
            _G.richieTargetName=""
            targetResolved.Text=""
        end
    end)
end)

local arrowOpen=true
local arrowBtn=Instance.new("TextButton")
arrowBtn.Size=UDim2.new(1,-6,0,34)
arrowBtn.BackgroundColor3=Color3.fromRGB(30,30,36)
arrowBtn.BackgroundTransparency=0.3
arrowBtn.Text=""
arrowBtn.BorderSizePixel=0
arrowBtn.AutoButtonColor=false
arrowBtn.Parent=TargetPage
Instance.new("UICorner",arrowBtn).CornerRadius=UDim.new(0,8)
local arrowLabel=Instance.new("TextLabel")
arrowLabel.Size=UDim2.new(1,-40,1,0)
arrowLabel.Position=UDim2.new(0,14,0,0)
arrowLabel.BackgroundTransparency=1
arrowLabel.Text="Target Actions"
arrowLabel.TextColor3=Color3.fromRGB(220,220,220)
arrowLabel.Font=Enum.Font.GothamSemibold
arrowLabel.TextSize=13
arrowLabel.TextXAlignment=Enum.TextXAlignment.Left
arrowLabel.Parent=arrowBtn
local arrowIcon=Instance.new("TextLabel")
arrowIcon.Size=UDim2.new(0,20,1,0)
arrowIcon.Position=UDim2.new(1,-26,0,0)
arrowIcon.BackgroundTransparency=1
arrowIcon.Text="▼"
arrowIcon.TextColor3=Color3.fromRGB(80,200,120)
arrowIcon.Font=Enum.Font.GothamBold
arrowIcon.TextSize=12
arrowIcon.Parent=arrowBtn


local targetContainer=Instance.new("Frame")
targetContainer.Size=UDim2.new(1,-6,0,0)
targetContainer.AutomaticSize=Enum.AutomaticSize.Y
targetContainer.BackgroundTransparency=1
targetContainer.Parent=TargetPage
local targetLayout=Instance.new("UIListLayout",targetContainer)
targetLayout.Padding=UDim.new(0,6)
targetLayout.SortOrder=Enum.SortOrder.LayoutOrder
arrowBtn.MouseButton1Click:Connect(function()
    arrowOpen=not arrowOpen
    targetContainer.Visible=arrowOpen
    arrowIcon.Text=arrowOpen and "▼" or "▶"
end)

_G.spectateC=nil
mkTog(targetContainer,"Spectate",function(on)
    if on then
        _G.spectateC=R.RenderStepped:Connect(function()
            local tg=_G.richieTarget
            if tg and tg.Character and tg.Character:FindFirstChild("Humanoid") then
                C.CameraSubject=tg.Character.Humanoid
            end
        end)
    else
        if _G.spectateC then _G.spectateC:Disconnect() _G.spectateC=nil end
        if LP.Character and LP.Character:FindFirstChild("Humanoid") then
            C.CameraSubject=LP.Character.Humanoid
        end
    end
end)

mkBtn(targetContainer,"Teleport to Target",function()
    local tg=_G.richieTarget
    if not tg then return end
    local ch=getCh()
    local hrp=ch:FindFirstChild("HumanoidRootPart")
    if hrp and tg.Character and tg.Character:FindFirstChild("HumanoidRootPart") then
        hrp.CFrame=tg.Character.HumanoidRootPart.CFrame*CFrame.new(0,3,0)
    end
end)

_G.targetEspC=nil
mkTog(targetContainer,"ESP Target",function(on)
    if on then
        _G.targetEspC=R.Heartbeat:Connect(function()
            local tg=_G.richieTarget
            if tg and tg.Character then
                if not tg.Character:FindFirstChild("RichieHighlight") then
                    local hl=Instance.new("Highlight")
                    hl.Name="RichieHighlight"
                    hl.FillColor=rgbC(espColors.esp)
                    hl.OutlineColor=Color3.fromRGB(255,255,255)
                    hl.FillTransparency=0.5
                    hl.Adornee=tg.Character
                    hl.Parent=tg.Character
                end
            end
        end)
    else
        if _G.targetEspC then _G.targetEspC:Disconnect() _G.targetEspC=nil end
        for _,p in pairs(P:GetPlayers()) do
            if p.Character then
                local h=p.Character:FindFirstChild("RichieHighlight")
                if h then h:Destroy() end
            end
        end
    end
end)

_G.targetDistGui=nil
_G.targetDistC=nil
mkTog(targetContainer,"Distance ESP",function(on)
    if on then
        _G.targetDistC=R.Heartbeat:Connect(function()
            local tg=_G.richieTarget
            if not tg or not tg.Character then
                if _G.targetDistGui then _G.targetDistGui:Destroy() _G.targetDistGui=nil end
                return
            end
            local head=tg.Character:FindFirstChild("Head")
            local myHrp=LP.Character and LP.Character:FindFirstChild("HumanoidRootPart")
            local tHrp=tg.Character:FindFirstChild("HumanoidRootPart") or tg.Character:FindFirstChild("UpperTorso") or tg.Character:FindFirstChild("Torso") or tg.Character:FindFirstChildWhichIsA("BasePart")
            if not head or not myHrp or not tHrp then return end
            if not _G.targetDistGui or not _G.targetDistGui.Parent then
                _G.targetDistGui=Instance.new("BillboardGui")
                _G.targetDistGui.Size=UDim2.new(0,150,0,20)
                _G.targetDistGui.StudsOffset=Vector3.new(0,4,0)
                _G.targetDistGui.AlwaysOnTop=true
                _G.targetDistGui.Adornee=head
                _G.targetDistGui.Parent=head
                local lbl=Instance.new("TextLabel")
                lbl.Name="DistLabel"
                lbl.Size=UDim2.new(1,0,1,0)
                lbl.BackgroundTransparency=1
                lbl.TextColor3=Color3.fromRGB(80,255,80)
                lbl.TextStrokeTransparency=0
                lbl.Font=Enum.Font.GothamBold
                lbl.TextSize=14
                lbl.Parent=_G.targetDistGui
            end
            local d=math.floor((myHrp.Position-tHrp.Position).Magnitude)
            local lbl=_G.targetDistGui:FindFirstChild("DistLabel")
            if lbl then lbl.Text=d.." studs" end
        end)
    else
        if _G.targetDistC then _G.targetDistC:Disconnect() _G.targetDistC=nil end
        if _G.targetDistGui then _G.targetDistGui:Destroy() _G.targetDistGui=nil end
    end
end)

_G.targetNameGui=nil
_G.targetNameC=nil
mkTog(targetContainer,"Name ESP",function(on)
    if on then
        _G.targetNameC=R.Heartbeat:Connect(function()
            local tg=_G.richieTarget
            if not tg or not tg.Character then
                if _G.targetNameGui then _G.targetNameGui:Destroy() _G.targetNameGui=nil end
                return
            end
            local head=tg.Character:FindFirstChild("Head") or tg.Character:FindFirstChild("UpperTorso") or tg.Character:FindFirstChild("Torso") or tg.Character:FindFirstChildWhichIsA("BasePart")
            if not head then return end
            if not _G.targetNameGui or not _G.targetNameGui.Parent then
                _G.targetNameGui=Instance.new("BillboardGui")
                _G.targetNameGui.Size=UDim2.new(0,200,0,30)
                _G.targetNameGui.StudsOffset=Vector3.new(0,3,0)
                _G.targetNameGui.AlwaysOnTop=true
                _G.targetNameGui.Adornee=head
                _G.targetNameGui.Parent=head
                local lbl=Instance.new("TextLabel")
                lbl.Size=UDim2.new(1,0,1,0)
                lbl.BackgroundTransparency=1
                lbl.Text=tg.Name
                lbl.TextColor3=Color3.fromRGB(255,80,80)
                lbl.TextStrokeTransparency=0
                lbl.Font=Enum.Font.GothamBold
                lbl.TextSize=14
                lbl.Parent=_G.targetNameGui
            end
        end)
    else
        if _G.targetNameC then _G.targetNameC:Disconnect() _G.targetNameC=nil end
        if _G.targetNameGui then _G.targetNameGui:Destroy() _G.targetNameGui=nil end
    end
end)

_G.targetBoxGui=nil
_G.targetBoxC=nil
mkTog(targetContainer,"Box ESP",function(on)
    if on then
        _G.targetBoxC=R.Heartbeat:Connect(function()
            local tg=_G.richieTarget
            if not tg or not tg.Character then
                if _G.targetBoxGui then _G.targetBoxGui:Destroy() _G.targetBoxGui=nil end
                return
            end
            local hrp=tg.Character:FindFirstChild("HumanoidRootPart")
            if not hrp then return end
            if not _G.targetBoxGui or not _G.targetBoxGui.Parent then
                _G.targetBoxGui=Instance.new("BillboardGui")
                _G.targetBoxGui.Size=UDim2.new(0,40,0,60)
                _G.targetBoxGui.AlwaysOnTop=true
                _G.targetBoxGui.Adornee=hrp
                _G.targetBoxGui.Parent=hrp
                local fr=Instance.new("Frame")
                fr.Size=UDim2.new(1,0,1,0)
                fr.BackgroundTransparency=1
                fr.Parent=_G.targetBoxGui
                local stroke=Instance.new("UIStroke",fr)
                stroke.Thickness=2
                local ec=_G.richieEspColors and _G.richieEspColors.box; stroke.Color=ec and Color3.fromRGB(ec.r,ec.g,ec.b) or Color3.fromRGB(255,80,80)
                Instance.new("UICorner",fr).CornerRadius=UDim.new(0,6)
            end
        end)
    else
        if _G.targetBoxC then _G.targetBoxC:Disconnect() _G.targetBoxC=nil end
        if _G.targetBoxGui then _G.targetBoxGui:Destroy() _G.targetBoxGui=nil end
    end
end)

_G.targetHpGui=nil
_G.targetHpC=nil
mkTog(targetContainer,"Health Bar ESP",function(on)
    if on then
        _G.targetHpC=R.Heartbeat:Connect(function()
            local tg=_G.richieTarget
            if not tg or not tg.Character then
                if _G.targetHpGui then _G.targetHpGui:Destroy() _G.targetHpGui=nil end
                return
            end
            local hrp=tg.Character:FindFirstChild("HumanoidRootPart")
            local hm=tg.Character:FindFirstChild("Humanoid")
            if not hrp or not hm then return end
            if not _G.targetHpGui or not _G.targetHpGui.Parent then
                _G.targetHpGui=Instance.new("BillboardGui")
                _G.targetHpGui.Size=UDim2.new(0,50,0,6)
                _G.targetHpGui.StudsOffset=Vector3.new(0,-3,0)
                _G.targetHpGui.AlwaysOnTop=true
                _G.targetHpGui.Adornee=hrp
                _G.targetHpGui.Parent=hrp
                local fill=Instance.new("Frame")
                fill.Name="HpFill"
                fill.Size=UDim2.new(1,0,1,0)
                fill.BackgroundColor3=Color3.fromRGB(80,255,80)
                fill.BorderSizePixel=0
                fill.Parent=_G.targetHpGui
                Instance.new("UICorner",fill).CornerRadius=UDim.new(1,0)
            end
            local ratio=math.clamp(hm.Health/hm.MaxHealth,0,1)
            local fill=_G.targetHpGui:FindFirstChild("HpFill")
            if fill then
                fill.Size=UDim2.new(ratio,0,1,0)
                if ratio<0.3 then
                    fill.BackgroundColor3=Color3.fromRGB(255,80,80)
                elseif ratio<0.6 then
                    fill.BackgroundColor3=Color3.fromRGB(255,220,80)
                else
                    fill.BackgroundColor3=Color3.fromRGB(80,255,80)
                end
            end
        end)
    else
        if _G.targetHpC then _G.targetHpC:Disconnect() _G.targetHpC=nil end
        if _G.targetHpGui then _G.targetHpGui:Destroy() _G.targetHpGui=nil end
    end
end)

_G.camlockC=nil
mkTog(targetContainer,"Camlock",function(on)
    if on then
        _G.camlockC=R.RenderStepped:Connect(function()
            local tg=_G.richieTarget
            local th=tg and tg.Character and (tg.Character:FindFirstChild("Head") or tg.Character:FindFirstChild("UpperTorso") or tg.Character:FindFirstChild("Torso"))
            if tg and tg.Character and th then
                C.CFrame=CFrame.new(C.CFrame.Position, th.Position)
            end
        end)
    else
        if _G.camlockC then _G.camlockC:Disconnect() _G.camlockC=nil end
    end
end)

-- ============ MULTI TARGET ============
do
mkLabel(TargetPage,"MULTI TARGET")

local multiSelected = {}
_G.richieMultiSelected = multiSelected
local multiOn = {esp=false, box=false, name=false, health=false, dist=false}
local multiGuis = {}

local function destroyMultiData(p)
    local data = multiGuis[p]
    if not data then return end
    if data.hl then data.hl:Destroy() end
    if data.nameBg then data.nameBg:Destroy() end
    if data.box then data.box:Destroy() end
    if data.hpBg then data.hpBg:Destroy() end
    if data.distBg then data.distBg:Destroy() end
    if data.hpConn then data.hpConn:Disconnect() end
    multiGuis[p] = nil
end

local function clearAllMultiData()
    for p, _ in pairs(multiGuis) do
        destroyMultiData(p)
    end
    multiGuis = {}
end

local function applyMultiFeatures(p)
    if not p.Character then return end
    local char = p.Character
    local hrp = char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("UpperTorso") or char:FindFirstChild("Torso") or char:FindFirstChildWhichIsA("BasePart")
    local head = char:FindFirstChild("Head") or hrp
    local hm = char:FindFirstChild("Humanoid") or char:FindFirstChildOfClass("Humanoid")
    if not hrp or not head or not hm then return end

    local data = multiGuis[p] or {p = p}
    multiGuis[p] = data

    if multiOn.esp then
        if not data.hl or not data.hl.Parent then
            local hl = Instance.new("Highlight")
            hl.Name = "RichieMultiHL"
            hl.FillColor = Color3.fromRGB(80, 200, 255)
            hl.OutlineColor = Color3.fromRGB(255, 255, 255)
            hl.FillTransparency = 0.5
            hl.Adornee = char
            hl.Parent = char
            data.hl = hl
        end
    else
        if data.hl then data.hl:Destroy() data.hl = nil end
    end

    if multiOn.name then
        if not data.nameBg or not data.nameBg.Parent then
            local nameBg = Instance.new("BillboardGui")
            nameBg.Size = UDim2.new(0, 200, 0, 30)
            nameBg.StudsOffset = Vector3.new(0, 3, 0)
            nameBg.AlwaysOnTop = true
            nameBg.Adornee = head
            nameBg.Parent = head
            local nameLbl = Instance.new("TextLabel")
            nameLbl.Size = UDim2.new(1,0,1,0)
            nameLbl.BackgroundTransparency = 1
            nameLbl.Text = p.Name
            nameLbl.TextColor3 = Color3.fromRGB(80, 200, 255)
            nameLbl.TextStrokeTransparency = 0
            nameLbl.Font = Enum.Font.GothamBold
            nameLbl.TextSize = 14
            nameLbl.Parent = nameBg
            data.nameBg = nameBg
        end
    else
        if data.nameBg then data.nameBg:Destroy() data.nameBg = nil end
    end

    if multiOn.box then
        if not data.box or not data.box.Parent then
            local box = Instance.new("BillboardGui")
            box.Size = UDim2.new(0, 40, 0, 60)
            box.AlwaysOnTop = true
            box.Adornee = hrp
            box.Parent = hrp
            local boxFr = Instance.new("Frame")
            boxFr.Size = UDim2.new(1,0,1,0)
            boxFr.BackgroundTransparency = 1
            boxFr.Parent = box
            local boxStroke = Instance.new("UIStroke", boxFr)
            boxStroke.Thickness = 2
            boxStroke.Color = Color3.fromRGB(80, 200, 255)
            Instance.new("UICorner", boxFr).CornerRadius = UDim.new(0, 6)
            data.box = box
        end
    else
        if data.box then data.box:Destroy() data.box = nil end
    end

    if multiOn.health then
        if not data.hpBg or not data.hpBg.Parent then
            local hpBg = Instance.new("BillboardGui")
            hpBg.Size = UDim2.new(0, 50, 0, 6)
            hpBg.StudsOffset = Vector3.new(0, -3, 0)
            hpBg.AlwaysOnTop = true
            hpBg.Adornee = hrp
            hpBg.Parent = hrp
            local hpFill = Instance.new("Frame")
            hpFill.Size = UDim2.new(1,0,1,0)
            hpFill.BackgroundColor3 = Color3.fromRGB(80, 255, 80)
            hpFill.BorderSizePixel = 0
            hpFill.Parent = hpBg
            Instance.new("UICorner", hpFill).CornerRadius = UDim.new(1, 0)
            local hpConn = hm.HealthChanged:Connect(function(h)
                local ratio = math.clamp(h/hm.MaxHealth, 0, 1)
                hpFill.Size = UDim2.new(ratio, 0, 1, 0)
                if ratio < 0.3 then
                    hpFill.BackgroundColor3 = Color3.fromRGB(255,80,80)
                elseif ratio < 0.6 then
                    hpFill.BackgroundColor3 = Color3.fromRGB(255,220,80)
                else
                    hpFill.BackgroundColor3 = Color3.fromRGB(80,255,80)
                end
            end)
            data.hpBg = hpBg
            data.hpConn = hpConn
        end
    else
        if data.hpBg then data.hpBg:Destroy() data.hpBg = nil end
        if data.hpConn then data.hpConn:Disconnect() data.hpConn = nil end
    end

    if multiOn.dist then
        if not data.distBg or not data.distBg.Parent then
            local distBg = Instance.new("BillboardGui")
            distBg.Size = UDim2.new(0, 150, 0, 20)
            distBg.StudsOffset = Vector3.new(0, 4.5, 0)
            distBg.AlwaysOnTop = true
            distBg.Adornee = head
            distBg.Parent = head
            local distLbl = Instance.new("TextLabel")
            distLbl.Size = UDim2.new(1,0,1,0)
            distLbl.BackgroundTransparency = 1
            distLbl.Text = "0 studs"
            distLbl.TextColor3 = Color3.fromRGB(80, 200, 255)
            distLbl.TextStrokeTransparency = 0
            distLbl.Font = Enum.Font.GothamBold
            distLbl.TextSize = 12
            distLbl.Parent = distBg
            data.distBg = distBg
            data.distLbl = distLbl
        end
    else
        if data.distBg then data.distBg:Destroy() data.distBg = nil end
    end
end

task.spawn(function()
    while true do
        task.wait(0.2)
        local myHrp = LP.Character and LP.Character:FindFirstChild("HumanoidRootPart")
        for p, data in pairs(multiGuis) do
            if data.distLbl and data.distBg and data.distBg.Parent and myHrp and p.Character then
                local tHrp = p.Character:FindFirstChild("HumanoidRootPart") or p.Character:FindFirstChild("UpperTorso") or p.Character:FindFirstChild("Torso")
                if tHrp then
                    local d = math.floor((myHrp.Position - tHrp.Position).Magnitude)
                    data.distLbl.Text = d.." studs"
                end
            end
        end
    end
end)

local multiContainer = Instance.new("Frame")
multiContainer.Size = UDim2.new(1,-6,0,0)
multiContainer.BackgroundColor3 = Color3.fromRGB(25,25,30)
multiContainer.BackgroundTransparency = 0.3
multiContainer.BorderSizePixel = 0
multiContainer.Visible = false
multiContainer.Parent = TargetPage
Instance.new("UICorner",multiContainer).CornerRadius = UDim.new(0,8)
local multiList = Instance.new("UIListLayout",multiContainer)
multiList.Padding = UDim.new(0,4)
multiList.SortOrder = Enum.SortOrder.LayoutOrder

local multiToggleBtn = Instance.new("TextButton")
multiToggleBtn.Size = UDim2.new(1,-6,0,36)
multiToggleBtn.BackgroundColor3 = Color3.fromRGB(30,30,36)
multiToggleBtn.BackgroundTransparency = 0.2
multiToggleBtn.Text = "Show Multi-Target List ▼"
multiToggleBtn.TextColor3 = Color3.fromRGB(220,220,220)
multiToggleBtn.Font = Enum.Font.GothamBold
multiToggleBtn.TextSize = 13
multiToggleBtn.BorderSizePixel = 0
multiToggleBtn.AutoButtonColor = false
multiToggleBtn.Parent = TargetPage
Instance.new("UICorner",multiToggleBtn).CornerRadius = UDim.new(0,8)

local multiToggleOpen = false

local function refreshMultiList()
    for _, c in pairs(multiContainer:GetChildren()) do
        if c:IsA("Frame") then c:Destroy() end
    end
    local players = {}
    for _, p in pairs(P:GetPlayers()) do
        if p ~= LP then table.insert(players, p) end
    end
    if #players == 0 then
        local empty = Instance.new("Frame")
        empty.Size = UDim2.new(1,0,0,40)
        empty.BackgroundTransparency = 1
        empty.LayoutOrder = 1
        empty.Parent = multiContainer
        local lbl = Instance.new("TextLabel")
        lbl.Size = UDim2.new(1,0,1,0)
        lbl.BackgroundTransparency = 1
        lbl.Text = "No players"
        lbl.TextColor3 = Color3.fromRGB(150,150,150)
        lbl.Font = Enum.Font.Gotham
        lbl.TextSize = 13
        lbl.Parent = empty
        multiContainer.Size = UDim2.new(1,-6,0, 8 + 40)
        return
    end
    for i, p in ipairs(players) do
        local row = Instance.new("Frame")
        row.Size = UDim2.new(1,-8,0,44)
        row.Position = UDim2.new(0,4,0,0)
        row.BackgroundColor3 = Color3.fromRGB(35,35,42)
        row.BackgroundTransparency = 0.4
        row.BorderSizePixel = 0
        row.LayoutOrder = i
        row.Parent = multiContainer
        Instance.new("UICorner",row).CornerRadius = UDim.new(0,6)

        local avatar = Instance.new("ImageLabel")
        avatar.Size = UDim2.new(0, 32, 0, 32)
        avatar.Position = UDim2.new(0, 6, 0.5, -16)
        avatar.BackgroundColor3 = Color3.fromRGB(60,60,70)
        avatar.BorderSizePixel = 0
        avatar.Parent = row
        Instance.new("UICorner",avatar).CornerRadius = UDim.new(1,0)
        pcall(function()
            local thumb = P:GetUserThumbnailAsync(p.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)
            avatar.Image = thumb
        end)

        local nameLbl = Instance.new("TextLabel")
        nameLbl.Size = UDim2.new(1,-90,0,20)
        nameLbl.Position = UDim2.new(0, 44, 0, 4)
        nameLbl.BackgroundTransparency = 1
        nameLbl.Text = p.DisplayName
        nameLbl.TextColor3 = Color3.fromRGB(240,240,240)
        nameLbl.Font = Enum.Font.GothamBold
        nameLbl.TextSize = 12
        nameLbl.TextXAlignment = Enum.TextXAlignment.Left
        nameLbl.TextTruncate = Enum.TextTruncate.AtEnd
        nameLbl.Parent = row

        local userLbl = Instance.new("TextLabel")
        userLbl.Size = UDim2.new(1,-90,0,14)
        userLbl.Position = UDim2.new(0, 44, 0, 24)
        userLbl.BackgroundTransparency = 1
        userLbl.Text = "@"..p.Name
        userLbl.TextColor3 = Color3.fromRGB(140,140,150)
        userLbl.Font = Enum.Font.Gotham
        userLbl.TextSize = 10
        userLbl.TextXAlignment = Enum.TextXAlignment.Left
        userLbl.TextTruncate = Enum.TextTruncate.AtEnd
        userLbl.Parent = row

        local checkbox = Instance.new("Frame")
        checkbox.Size = UDim2.new(0, 22, 0, 22)
        checkbox.Position = UDim2.new(1, -30, 0.5, -11)
        checkbox.BackgroundColor3 = multiSelected[p] and Color3.fromRGB(80,200,120) or Color3.fromRGB(50,50,60)
        checkbox.BorderSizePixel = 0
        checkbox.Parent = row
        Instance.new("UICorner",checkbox).CornerRadius = UDim.new(0,5)

        local checkMark = Instance.new("TextLabel")
        checkMark.Size = UDim2.new(1,0,1,0)
        checkMark.BackgroundTransparency = 1
        checkMark.Text = multiSelected[p] and "✓" or ""
        checkMark.TextColor3 = Color3.fromRGB(255,255,255)
        checkMark.Font = Enum.Font.GothamBold
        checkMark.TextSize = 14
        checkMark.Parent = checkbox

        local click = Instance.new("TextButton")
        click.Size = UDim2.new(1,0,1,0)
        click.BackgroundTransparency = 1
        click.Text = ""
        click.Parent = row
        click.MouseButton1Click:Connect(function()
            multiSelected[p] = not multiSelected[p]
            checkbox.BackgroundColor3 = multiSelected[p] and Color3.fromRGB(80,200,120) or Color3.fromRGB(50,50,60)
            checkMark.Text = multiSelected[p] and "✓" or ""
            if multiSelected[p] then
                applyMultiFeatures(p)
            else
                destroyMultiData(p)
            end
        end)
    end
    multiContainer.Size = UDim2.new(1,-6,0, 8 + #players * 48)
end

multiToggleBtn.MouseButton1Click:Connect(function()
    multiToggleOpen = not multiToggleOpen
    multiContainer.Visible = multiToggleOpen
    multiToggleBtn.Text = multiToggleOpen and "Hide Multi-Target List ▲" or "Show Multi-Target List ▼"
    if multiToggleOpen then refreshMultiList() end
end)

task.spawn(function()
    while true do
        task.wait(1.5)
        if multiToggleOpen then
            refreshMultiList()
        end
    end
end)

mkTog(TargetPage,"Multi ESP",function(on)
    multiOn.esp = on
    for p, sel in pairs(multiSelected) do
        if sel and p.Character then applyMultiFeatures(p) end
    end
end)

mkTog(TargetPage,"Multi Box ESP",function(on)
    multiOn.box = on
    for p, sel in pairs(multiSelected) do
        if sel and p.Character then applyMultiFeatures(p) end
    end
end)

mkTog(TargetPage,"Multi Name ESP",function(on)
    multiOn.name = on
    for p, sel in pairs(multiSelected) do
        if sel and p.Character then applyMultiFeatures(p) end
    end
end)

mkTog(TargetPage,"Multi Health Bar ESP",function(on)
    multiOn.health = on
    for p, sel in pairs(multiSelected) do
        if sel and p.Character then applyMultiFeatures(p) end
    end
end)

mkTog(TargetPage,"Multi Distance ESP",function(on)
    multiOn.dist = on
    for p, sel in pairs(multiSelected) do
        if sel and p.Character then applyMultiFeatures(p) end
    end
end)

mkBtn(TargetPage,"Clear Multi Selection",function()
    multiSelected = {}
    clearAllMultiData()
    refreshMultiList()
    notify("Multi selection cleared")
end)
end
end

-- ============ RESPAWN ============
local function applySaved(ch)
    if not ch then return end
    local hm=ch:WaitForChild("Humanoid",10)
    if not hm then return end
    task.wait(1.5)
    hm.WalkSpeed=savedValues["speed"] or 16
    hm.UseJumpPower=true
    hm.JumpPower=savedValues["jump"] or 50
    C.FieldOfView=savedValues["fov"] or 70
    W.Gravity=savedValues["grav"] or origGrav
end

LP.CharacterAdded:Connect(function()
    if feInvisData and feInvisData.seat then
        feInvisData.seat:Destroy()
    end
    feInvisData=nil
    feInvisOn=false
end)

LP.CharacterAdded:Connect(function(ch)
    task.wait(0.5)
    applySaved(ch)
end)
if LP.Character then
    task.spawn(function() applySaved(LP.Character) end)
end

-- ============ CLOSE ============
Cl.MouseButton1Click:Connect(function() pcall(function()
    pcall(stopFly)
    pcall(_G.richieCombatCleanup)
    pcall(_G.richieWeatherCleanup)
    pcall(_G.richieSkyCleanup)
    pcall(_G.richieVisualsCleanup)
    for _, p in pairs(P:GetPlayers()) do
        if p.Character then
            for _, v in pairs(p.Character:GetDescendants()) do
                if v:IsA("Highlight") and (v.Name=="RichieHighlight" or v.Name=="RichieMultiHL") then v:Destroy() end
                if v:IsA("BillboardGui") and v.Name~="" and v.Parent then end
            end
        end
    end
    for _, v in pairs(W:GetDescendants()) do
        if v.Name=="RichieHitboxEsp" or v.Name=="RichieRain" or v.Name=="RichieSnow" or v.Name=="RichieBolt" or v.Name=="RichieColorSky" or v.Name=="RichieFEChair" or v.Name=="RichieWeather" then
            pcall(function() v:Destroy() end)
        end
    end
    for _, v in pairs(L:GetChildren()) do
        if v.Name=="RichieColorSky" then v:Destroy() end
    end
    if _G.richieIJ then _G.richieIJ:Disconnect() end
    if _G.richieNoclip then _G.richieNoclip:Disconnect() end
    if _G.richieAntiSit then _G.richieAntiSit:Disconnect() end
    if _G.richieAntiSitBlock then _G.richieAntiSitBlock:Disconnect() end
    if _G.richieAntiFling then _G.richieAntiFling:Disconnect() end
    if _G.richieFreeze then _G.richieFreeze:Disconnect() end
    if _G.richieAntiKick then _G.richieAntiKick:Disconnect() end
    if _G.spectateC then _G.spectateC:Disconnect() end
    if _G.targetEspC then _G.targetEspC:Disconnect() end
    if _G.targetDistC then _G.targetDistC:Disconnect() end
    if _G.targetDistGui then _G.targetDistGui:Destroy() end
    if _G.targetNameC then _G.targetNameC:Disconnect() end
    if _G.targetNameGui then _G.targetNameGui:Destroy() end
    if _G.targetBoxC then _G.targetBoxC:Disconnect() end
    if _G.targetBoxGui then _G.targetBoxGui:Destroy() end
    if _G.targetHpC then _G.targetHpC:Disconnect() end
    if _G.targetHpGui then _G.targetHpGui:Destroy() end
    if _G.camlockC then _G.camlockC:Disconnect() end
    local ch=LP.Character
    if ch then
        local hm=ch:FindFirstChild("Humanoid")
        if hm then
            hm.WalkSpeed=16
            hm.UseJumpPower=true
            hm.JumpPower=50
            hm.PlatformStand=false
            hm.DisplayDistanceType=Enum.HumanoidDisplayDistanceType.Viewer
        end
        for _,p in pairs(ch:GetDescendants()) do
            if p:IsA("BasePart") then
                p.CanCollide=true
                p.Transparency=0
                p.Anchored=false
            end
        end
    end
    L.Ambient=origAmb
    L.OutdoorAmbient=origOutdoor
    L.FogStart=origFogStart
    L.FogEnd=origFogEnd
    L.Brightness=origBright
    L.FogColor=Color3.fromRGB(192,192,192)
    L.ClockTime=14
    L.ColorShift_Top=Color3.fromRGB(0,0,0)
    L.ColorShift_Bottom=Color3.fromRGB(0,0,0)
    W.Gravity=origGrav
    LP.CameraMaxZoomDistance=128
    LP.CameraMinZoomDistance=0.5
    C.FieldOfView=70
    if C.CameraSubject ~= (LP.Character and LP.Character:FindFirstChild("Humanoid")) then
        if LP.Character and LP.Character:FindFirstChild("Humanoid") then
            C.CameraSubject=LP.Character.Humanoid
        end
    end
    _G.richieTarget=nil
    _G.richieTargetName=nil
    _G.richieMultiSelected=nil
    _G.richieEspColors=nil
    _G.richieToggleState=nil
    _G.richieCombatCleanup=nil
    _G.richieWeatherCleanup=nil
    _G.richieSkyCleanup=nil
    _G.richieVisualsCleanup=nil
    _G.richieARRestore=nil
    _G.richieIJ=nil
    _G.richieNoclip=nil
    _G.richieAntiSit=nil
    _G.richieAntiSitBlock=nil
    _G.richieAntiFling=nil
    _G.richieFreeze=nil
    _G.richieAntiKick=nil
    _G.spectateC=nil
    _G.targetEspC=nil
    _G.targetDistC=nil
    _G.targetDistGui=nil
    _G.targetNameC=nil
    _G.targetNameGui=nil
    _G.targetBoxC=nil
    _G.targetBoxGui=nil
    _G.targetHpC=nil
    _G.targetHpGui=nil
    _G.camlockC=nil
    end)
    for _, gui in pairs(pg:GetDescendants()) do
        if gui:IsA("ScreenGui") and (gui.Name=="RichieHubUI" or gui.Name=="RichieCrosshair" or gui.Name=="RichieAimFov" or gui.Name=="RichieFovCircle") then
            gui:Destroy()
        end
    end
    for _, v in pairs(getgc and getgc(true) or {}) do
        if type(v)=="table" and rawget(v,"__name")=="Richie" then end
    end
end)

-- ============ KEYBINDS ============
local keybindData = {}
local listeningForKey = nil
local listeningBtn = nil

local unsupportedKeys = {
    [Enum.KeyCode.W]=true,[Enum.KeyCode.A]=true,[Enum.KeyCode.S]=true,[Enum.KeyCode.D]=true,
    [Enum.KeyCode.Space]=true,[Enum.KeyCode.Delete]=true,
    [Enum.KeyCode.One]=true,[Enum.KeyCode.Two]=true,[Enum.KeyCode.Three]=true,
    [Enum.KeyCode.Four]=true,[Enum.KeyCode.Five]=true,[Enum.KeyCode.Six]=true,
    [Enum.KeyCode.Seven]=true,[Enum.KeyCode.Eight]=true,[Enum.KeyCode.Nine]=true,
    [Enum.KeyCode.Zero]=true,
    [Enum.KeyCode.F1]=true,[Enum.KeyCode.F2]=true,[Enum.KeyCode.F3]=true,
    [Enum.KeyCode.F4]=true,[Enum.KeyCode.F5]=true,[Enum.KeyCode.F6]=true,
    [Enum.KeyCode.F7]=true,[Enum.KeyCode.F8]=true,[Enum.KeyCode.F9]=true,
    [Enum.KeyCode.F10]=true,[Enum.KeyCode.F11]=true,[Enum.KeyCode.F12]=true,
}

local function mkKeyHeader(parent, text)
    local l=Instance.new("TextLabel")
    l.Size=UDim2.new(1,-6,0,20)
    l.BackgroundTransparency=1
    l.Text="  ("..text..")"
    l.TextColor3=Color3.fromRGB(120,120,130)
    l.Font=Enum.Font.GothamBlack
    l.TextSize=10
    l.TextXAlignment=Enum.TextXAlignment.Left
    l.Parent=parent
end

local function mkKeybindRow(parent, featureName)
    local row=Instance.new("Frame")
    row.Size=UDim2.new(1,-6,0,36)
    row.BackgroundColor3=Color3.fromRGB(30,30,36)
    row.BackgroundTransparency=0.3
    row.BorderSizePixel=0
    row.Parent=parent
    Instance.new("UICorner",row).CornerRadius=UDim.new(0,8)

    local lbl=Instance.new("TextLabel")
    lbl.Size=UDim2.new(0.45,0,1,0)
    lbl.Position=UDim2.new(0,14,0,0)
    lbl.BackgroundTransparency=1
    lbl.Text=featureName
    lbl.TextColor3=Color3.fromRGB(220,220,220)
    lbl.Font=Enum.Font.GothamSemibold
    lbl.TextSize=13
    lbl.TextXAlignment=Enum.TextXAlignment.Left
    lbl.TextTruncate=Enum.TextTruncate.AtEnd
    lbl.Parent=row

    local btn=Instance.new("TextButton")
    btn.Size=UDim2.new(0.32,0,1,-8)
    btn.Position=UDim2.new(0.48,0,0,4)
    btn.BackgroundColor3=Color3.fromRGB(45,45,52)
    btn.BackgroundTransparency=0.2
    btn.Text="+"
    btn.TextColor3=Color3.fromRGB(220,220,220)
    btn.Font=Enum.Font.GothamBlack
    btn.TextSize=14
    btn.BorderSizePixel=0
    btn.AutoButtonColor=false
    btn.Parent=row
    Instance.new("UICorner",btn).CornerRadius=UDim.new(0,6)

    local resetBtn=Instance.new("TextButton")
    resetBtn.Size=UDim2.new(0.15,0,1,-8)
    resetBtn.Position=UDim2.new(0.83,0,0,4)
    resetBtn.BackgroundColor3=Color3.fromRGB(180,45,45)
    resetBtn.BackgroundTransparency=0.2
    resetBtn.Text="↺"
    resetBtn.TextColor3=Color3.fromRGB(255,255,255)
    resetBtn.Font=Enum.Font.GothamBlack
    resetBtn.TextSize=16
    resetBtn.BorderSizePixel=0
    resetBtn.AutoButtonColor=false
    resetBtn.Parent=row
    Instance.new("UICorner",resetBtn).CornerRadius=UDim.new(0,6)

    btn.MouseButton1Click:Connect(function()
        if listeningForKey then return end
        listeningForKey=featureName
        listeningBtn=btn
        btn.Text="..."
        btn.TextColor3=Color3.fromRGB(80,200,120)
    end)

    resetBtn.MouseButton1Click:Connect(function()
        keybindData[featureName] = nil
        btn.Text="+"
        btn.TextColor3=Color3.fromRGB(220,220,220)
    end)
end

local function onKeyPress(input)
    if not listeningForKey then return end
    if input.UserInputType ~= Enum.UserInputType.Keyboard then return end
    local key=input.KeyCode
    local btn=listeningBtn
    if unsupportedKeys[key] then
        btn.Text="Not Allowed"
        btn.TextColor3=Color3.fromRGB(255,80,80)
        task.wait(1)
        btn.Text="+"
        btn.TextColor3=Color3.fromRGB(220,220,220)
        listeningForKey=nil
        listeningBtn=nil
        return
    end
    if key==Enum.KeyCode.Unknown then return end
    for otherFeature, boundKey in pairs(keybindData) do
        if otherFeature ~= listeningForKey and boundKey == key then
            btn.Text="In Use"
            btn.TextColor3=Color3.fromRGB(255,80,80)
            task.wait(1)
            btn.Text="+"
            btn.TextColor3=Color3.fromRGB(220,220,220)
            listeningForKey=nil
            listeningBtn=nil
            return
        end
    end
    keybindData[listeningForKey] = key
    btn.Text=key.Name
    btn.TextColor3=Color3.fromRGB(80,200,120)
    listeningForKey=nil
    listeningBtn=nil
end

U.InputBegan:Connect(function(input, gameProcessed)
    if gameProcessed then return end
    if input.UserInputType ~= Enum.UserInputType.Keyboard then return end
    if listeningForKey then
        onKeyPress(input)
        return
    end
    for featureName, key in pairs(keybindData) do
        if input.KeyCode==key then
            if keybindTargets[featureName] then
                local tgt=keybindTargets[featureName]
                local current = _G.richieToggleState[featureName]
                if current == nil then current = false end
                local newState = not current
                _G.richieToggleState[featureName]=newState
                tgt.setState(newState)
                if tgt.onChange then tgt.onChange(newState) end
                notify(featureName .. ": " .. (newState and "ON" or "OFF"))
            elseif keybindButtons[featureName] then
                local info=keybindButtons[featureName]
                if info.fire then info.fire() end
                notify(featureName .. ": fired")
            end
        end
    end
end)

mkKeyHeader(KeybindPage,"MAIN")
mkKeybindRow(KeybindPage,"Fly")
mkKeybindRow(KeybindPage,"Auto-Sprint")
mkKeybindRow(KeybindPage,"Auto-Jump")
mkKeybindRow(KeybindPage,"Infinite Zoom")
mkKeybindRow(KeybindPage,"Infinite Jump")
mkKeybindRow(KeybindPage,"Noclip")
mkKeybindRow(KeybindPage,"FE Invisible (300 up)")
mkKeybindRow(KeybindPage,"Anti-Sit")
mkKeyHeader(KeybindPage,"COMBAT")
mkKeybindRow(KeybindPage,"Aim Assist")
mkKeybindRow(KeybindPage,"Target Lock")
mkKeybindRow(KeybindPage,"Trigger Bot")
mkKeybindRow(KeybindPage,"Anti-Aim")
mkKeybindRow(KeybindPage,"Hitbox Expander")
mkKeybindRow(KeybindPage,"Hitbox ESP Preview")

mkKeyHeader(KeybindPage,"VISUALS")
mkKeybindRow(KeybindPage,"ESP (Grey)")
mkKeybindRow(KeybindPage,"Box ESP")
mkKeybindRow(KeybindPage,"Health Bar ESP")
mkKeybindRow(KeybindPage,"Name ESP")
mkKeybindRow(KeybindPage,"Distance ESP")
mkKeybindRow(KeybindPage,"Skeleton ESP")

mkKeyHeader(KeybindPage,"WORLD")
mkKeybindRow(KeybindPage,"Server Hop")
mkKeybindRow(KeybindPage,"Anti-Kick")
mkKeybindRow(KeybindPage,"Anti-AFK")
mkKeybindRow(KeybindPage,"FPS Unlocker")
mkKeybindRow(KeybindPage,"Fullbright")
mkKeybindRow(KeybindPage,"No Fog")
mkKeybindRow(KeybindPage,"Low Gravity")
mkKeybindRow(KeybindPage,"Anti-Fling")
mkKeybindRow(KeybindPage,"Freeze Self")

mkKeyHeader(KeybindPage,"ACTIONS")
mkKeybindRow(KeybindPage,"Teleport to Mouse (PC Only, In Keybinds)")
mkKeybindRow(KeybindPage,"Reset Character")
mkKeybindRow(KeybindPage,"Rejoin Server")

print("[Richie Hub] loaded")

Features & Information

probably everything u need

Community Comments (1)

CH_NCH_WCH_NCH_WOct 8, 2026

AI?

More Scripts for Universal Scripts