CCCPaste

47c4661893da6

--================================================================================--
--==  ⚡ BADR HUB - TITAN EDITION V10 (Professional Grade)                     ==--
--==  💀 Features: Skeleton ESP | 🧱 Wall Check | 🎯 Silent Aim Logic          ==--
--==  🛡️ Key: BADR                                                            ==--
--================================================================================--

-- [1] SERVICES | الخدمات الأساسية
local Players = game:GetService("Players")
local CoreGui = game:GetService("CoreGui")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Workspace = game:GetService("Workspace")
local Camera = Workspace.CurrentCamera
local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()

-- [2] SETTINGS & CONFIG | إعدادات النظام
local Settings = {
    Key = "BADR",
    MainColor = Color3.fromRGB(0, 255, 255), -- Cyan Titan
    EnemyVisible = Color3.fromRGB(0, 255, 0), -- أخضر (مكشوف)
    EnemyHidden = Color3.fromRGB(255, 0, 0), -- أحمر (خلف جدار)
    TeamColor = Color3.fromRGB(0, 100, 255)
}

local Config = {
    ESP = {
        Enabled = false,
        Boxes = false,
        Skeletons = false, -- ميزة قوية
        Names = false,
        Health = false,
        Tracers = false,
        TeamCheck = true
    },
    Aimbot = {
        Enabled = false,
        WallCheck = true, -- لا يطلق النار خلف الجدار
        FOV = 100,
        Smoothness = 0.2,
        Key = Enum.UserInputType.MouseButton2,
        TargetPart = "Head"
    }
}

-- [3] LIBRARY & UTILS | دوال مساعدة قوية
local function IsAlive(plr)
    if plr and plr.Character and plr.Character:FindFirstChild("Humanoid") and plr.Character.Humanoid.Health > 0 and plr.Character:FindFirstChild("HumanoidRootPart") then
        return true
    end
    return false
end

local function IsVisible(targetPart)
    local origin = Camera.CFrame.Position
    local direction = (targetPart.Position - origin).Unit * (targetPart.Position - origin).Magnitude
    local raycastParams = RaycastParams.new()
    raycastParams.FilterDescendantsInstances = {LocalPlayer.Character, Camera}
    raycastParams.FilterType = Enum.RaycastFilterType.Exclude
    
    local result = Workspace:Raycast(origin, direction, raycastParams)
    if result then
        if result.Instance:IsDescendantOf(targetPart.Parent) then
            return true
        end
        return false
    end
    return true
end

-- [4] DRAWING LIBRARY (ESP ENGINE) | محرك الرسم
local ESP_Storage = {}

local function CreateDrawing(type, props)
    local d = Drawing.new(type)
    for k,v in pairs(props) do d[k] = v end
    return d
end

local function AddESP(plr)
    local Objects = {
        Box = CreateDrawing("Square", {Thickness = 1.5, Filled = false, Visible = false}),
        Tracer = CreateDrawing("Line", {Thickness = 1, Visible = false}),
        Name = CreateDrawing("Text", {Size = 14, Center = true, Outline = true, Color = Color3.White, Visible = false}),
        HPBar = CreateDrawing("Line", {Thickness = 2, Visible = false}),
        -- Skeleton Lines (R15/R6 Generic)
        Skeleton = {}
    }
    -- إنشاء خطوط الهيكل العظمي (10 خطوط أساسية)
    for i=1, 10 do table.insert(Objects.Skeleton, CreateDrawing("Line", {Thickness = 1.5, Color = Color3.White, Visible = false})) end
    
    ESP_Storage[plr] = Objects
end

local function RemoveESP(plr)
    if ESP_Storage[plr] then
        for _, v in pairs(ESP_Storage[plr]) do
            if type(v) == "table" then for _, line in pairs(v) do line:Remove() end -- Remove Skeleton
            else v:Remove() end
        end
        ESP_Storage[plr] = nil
    end
end

-- [5] ESP UPDATE LOOP (THE CORE) | حلقة التحديث المستمر
RunService.RenderStepped:Connect(function()
    for plr, ESP in pairs(ESP_Storage) do
        if plr ~= LocalPlayer and IsAlive(plr) then
            local char = plr.Character
            local hrp = char.HumanoidRootPart
            local hum = char.Humanoid
            
            local vec, onScreen = Camera:WorldToViewportPoint(hrp.Position)
            local isTeam = (Config.ESP.TeamCheck and plr.Team == LocalPlayer.Team)
            local isVis = IsVisible(hrp)
            
            -- تحديد اللون بناءً على الرؤية
            local currentColor = isVis and Settings.EnemyVisible or Settings.EnemyHidden
            if isTeam then currentColor = Settings.TeamColor end

            if onScreen and not isTeam and Config.ESP.Enabled then
                local rootPos = hrp.Position
                local headPos = char.Head.Position + Vector3.new(0, 0.5, 0)
                local legPos = rootPos - Vector3.new(0, 3, 0)
                
                local topVec = Camera:WorldToViewportPoint(headPos)
                local botVec = Camera:WorldToViewportPoint(legPos)
                local height = math.abs(topVec.Y - botVec.Y)
                local width = height / 1.6

                -- 1. Box ESP
                if Config.ESP.Boxes then
                    ESP.Box.Size = Vector2.new(width, height)
                    ESP.Box.Position = Vector2.new(topVec.X - width/2, topVec.Y)
                    ESP.Box.Color = currentColor
                    ESP.Box.Visible = true
                else ESP.Box.Visible = false end

                -- 2. Tracers
                if Config.ESP.Tracers then
                    ESP.Tracer.From = Vector2.new(Camera.ViewportSize.X/2, Camera.ViewportSize.Y)
                    ESP.Tracer.To = Vector2.new(botVec.X, botVec.Y)
                    ESP.Tracer.Color = currentColor
                    ESP.Tracer.Visible = true
                else ESP.Tracer.Visible = false end

                -- 3. Name & Health
                if Config.ESP.Names then
                    ESP.Name.Text = plr.Name .. " ["..math.floor(hum.Health).."]"
                    ESP.Name.Position = Vector2.new(topVec.X, topVec.Y - 15)
                    ESP.Name.Visible = true
                else ESP.Name.Visible = false end
                
                -- 4. Health Bar
                if Config.ESP.Health then
                    local hpHeight = height * (hum.Health / hum.MaxHealth)
                    ESP.HPBar.From = Vector2.new(topVec.X - width/2 - 5, botVec.Y)
                    ESP.HPBar.To = Vector2.new(topVec.X - width/2 - 5, botVec.Y - hpHeight)
                    ESP.HPBar.Color = Color3.fromRGB(0, 255, 0)
                    ESP.HPBar.Visible = true
                else ESP.HPBar.Visible = false end

                -- 5. SKELETON ESP (The Powerful Part)
                if Config.ESP.Skeletons then
                    -- R15 Joints Mapping
                    local joints = {
                        {"Head", "UpperTorso"}, {"UpperTorso", "LowerTorso"}, {"LowerTorso", "LeftUpperLeg"}, {"LeftUpperLeg", "LeftLowerLeg"},
                        {"LowerTorso", "RightUpperLeg"}, {"RightUpperLeg", "RightLowerLeg"}, {"UpperTorso", "LeftUpperArm"}, {"LeftUpperArm", "LeftLowerArm"},
                        {"UpperTorso", "RightUpperArm"}, {"RightUpperArm", "RightLowerArm"}
                    }
                    -- R6 Fallback (Simple)
                    if hum.RigType == Enum.HumanoidRigType.R6 then
                         joints = {{"Head", "Torso"}, {"Torso", "Left Leg"}, {"Torso", "Right Leg"}, {"Torso", "Left Arm"}, {"Torso", "Right Arm"}}
                    end

                    for i, partPair in ipairs(joints) do
                        local p1 = char:FindFirstChild(partPair[1])
                        local p2 = char:FindFirstChild(partPair[2])
                        local line = ESP.Skeleton[i]
                        
                        if p1 and p2 and line then
                            local v1, vis1 = Camera:WorldToViewportPoint(p1.Position)
                            local v2, vis2 = Camera:WorldToViewportPoint(p2.Position)
                            if vis1 and vis2 then
                                line.From = Vector2.new(v1.X, v1.Y)
                                line.To = Vector2.new(v2.X, v2.Y)
                                line.Color = currentColor
                                line.Visible = true
                            else line.Visible = false end
                        elseif line then line.Visible = false end
                    end
                else
                     for _, l in pairs(ESP.Skeleton) do l.Visible = false end
                end

            else
                -- Off Screen or Hidden
                for _, v in pairs(ESP) do 
                    if type(v)=="table" then for _,l in pairs(v) do l.Visible=false end
                    else v.Visible = false end 
                end
            end
        else
            -- Dead or removed
            if ESP_Storage[plr] then
                 for _, v in pairs(ESP) do 
                    if type(v)=="table" then for _,l in pairs(v) do l.Visible=false end
                    else v.Visible = false end 
                end
            end
        end
    end
end)

Players.PlayerAdded:Connect(AddESP)
Players.PlayerRemoving:Connect(RemoveESP)
for _, p in pairs(Players:GetPlayers()) do if p ~= LocalPlayer then AddESP(p) end end

-- [6] AIMBOT ENGINE | محرك التصويب
local FOVCircle = Drawing.new("Circle")
FOVCircle.Thickness = 1.5
FOVCircle.NumSides = 100
FOVCircle.Color = Settings.MainColor
FOVCircle.Filled = false

RunService.RenderStepped:Connect(function()
    FOVCircle.Position = Vector2.new(Mouse.X, Mouse.Y + 36) -- +36 accounts for GUI inset
    FOVCircle.Radius = Config.Aimbot.FOV
    FOVCircle.Visible = Config.Aimbot.Enabled

    if Config.Aimbot.Enabled and UserInputService:IsMouseButtonPressed(Config.Aimbot.Key) then
        local closest = nil
        local maxDist = math.huge

        for _, p in pairs(Players:GetPlayers()) do
            if p ~= LocalPlayer and IsAlive(p) then
                if Config.ESP.TeamCheck and p.Team == LocalPlayer.Team then continue end
                
                local part = p.Character[Config.Aimbot.TargetPart]
                local pos, onScreen = Camera:WorldToViewportPoint(part.Position)
                
                if onScreen then
                    local dist = (Vector2.new(Mouse.X, Mouse.Y) - Vector2.new(pos.X, pos.Y)).Magnitude
                    
                    -- Logic Checks (FOV + WallCheck)
                    if dist < Config.Aimbot.FOV and dist < maxDist then
                        if Config.Aimbot.WallCheck then
                            if IsVisible(part) then
                                maxDist = dist
                                closest = part
                            end
                        else
                            maxDist = dist
                            closest = part
                        end
                    end
                end
            end
        end

        if closest then
            local targetPos = Camera:WorldToViewportPoint(closest.Position)
            local mouseX, mouseY = Mouse.X, Mouse.Y
            local moveX = (targetPos.X - mouseX) * Config.Aimbot.Smoothness
            local moveY = (targetPos.Y - mouseY) * Config.Aimbot.Smoothness
            mousemoverel(moveX, moveY)
        end
    end
end)

-- [7] UI SETUP (TITAN THEME) | الواجهة
local ScreenGui = Instance.new("ScreenGui", CoreGui)
ScreenGui.Name = "BadrTitanV10"

local function MakeDraggable(frame)
    local dragToggle, dragInput, dragStart, startPos
    frame.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
            dragToggle = true
            dragStart = input.Position
            startPos = frame.Position
        end
    end)
    frame.InputChanged:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch then dragInput = input end
    end)
    UserInputService.InputChanged:Connect(function(input)
        if input == dragInput and dragToggle then
            local delta = input.Position - dragStart
            frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
        end
    end)
    frame.InputEnded:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then dragToggle = false end
    end)
end

-- LOGIN UI
local LoginFrame = Instance.new("Frame", ScreenGui)
LoginFrame.Size = UDim2.new(0, 300, 0, 150)
LoginFrame.Position = UDim2.new(0.5, -150, 0.5, -75)
LoginFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
LoginFrame.BorderSizePixel = 0
Instance.new("UICorner", LoginFrame).CornerRadius = UDim.new(0, 10)
MakeDraggable(LoginFrame)

local KeyBox = Instance.new("TextBox", LoginFrame)
KeyBox.Size = UDim2.new(0.8, 0, 0.3, 0)
KeyBox.Position = UDim2.new(0.1, 0, 0.3, 0)
KeyBox.PlaceholderText = "Enter Key: BADR"
KeyBox.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
KeyBox.TextColor3 = Color3.White
Instance.new("UICorner", KeyBox).CornerRadius = UDim.new(0, 6)

local EnterBtn = Instance.new("TextButton", LoginFrame)
EnterBtn.Size = UDim2.new(0.5, 0, 0.25, 0)
EnterBtn.Position = UDim2.new(0.25, 0, 0.7, 0)
EnterBtn.Text = "UNLOCK TITAN"
EnterBtn.BackgroundColor3 = Settings.MainColor
Instance.new("UICorner", EnterBtn).CornerRadius = UDim.new(0, 6)

-- MAIN UI
local MainFrame = Instance.new("Frame", ScreenGui)
MainFrame.Size = UDim2.new(0, 500, 0, 350)
MainFrame.Position = UDim2.new(0.5, -250, 0.5, -175)
MainFrame.BackgroundColor3 = Color3.fromRGB(15, 15, 15)
MainFrame.Visible = false
Instance.new("UICorner", MainFrame).CornerRadius = UDim.new(0, 10)
Instance.new("UIStroke", MainFrame).Color = Settings.MainColor
Instance.new("UIStroke", MainFrame).Thickness = 2
MakeDraggable(MainFrame)

-- TABS
local TabContainer = Instance.new("Frame", MainFrame)
TabContainer.Size = UDim2.new(0.25, 0, 1, 0)
TabContainer.BackgroundColor3 = Color3.fromRGB(25, 25, 25)
Instance.new("UICorner", TabContainer).CornerRadius = UDim.new(0, 10)

local ContentContainer = Instance.new("Frame", MainFrame)
ContentContainer.Size = UDim2.new(0.73, 0, 0.95, 0)
ContentContainer.Position = UDim2.new(0.27, 0, 0.025, 0)
ContentContainer.BackgroundTransparency = 1
local ContentLayout = Instance.new("UIListLayout", ContentContainer)
ContentLayout.Padding = UDim.new(0, 5)

local function CreateToggleBtn(text, tableRef, valName)
    local btn = Instance.new("TextButton", ContentContainer)
    btn.Size = UDim2.new(1, 0, 0, 40)
    btn.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
    btn.Text = text .. " [OFF]"
    btn.TextColor3 = Color3.White
    Instance.new("UICorner", btn).CornerRadius = UDim.new(0, 6)
    
    btn.MouseButton1Click:Connect(function()
        tableRef[valName] = not tableRef[valName]
        btn.Text = text .. (tableRef[valName] and " [ON]" or " [OFF]")
        btn.BackgroundColor3 = tableRef[valName] and Settings.MainColor or Color3.fromRGB(40, 40, 40)
        btn.TextColor3 = tableRef[valName] and Color3.Black or Color3.White
    end)
end

-- LOGIC
EnterBtn.MouseButton1Click:Connect(function()
    if KeyBox.Text == Settings.Key then
        LoginFrame:Destroy()
        MainFrame.Visible = true
    else
        KeyBox.Text = "WRONG KEY!"
        task.wait(1)
        KeyBox.Text = ""
    end
end)

-- TAB LOGIC GENERATION
local Tabs = {"Visuals", "Combat", "Settings"}
for i, tab in ipairs(Tabs) do
    local tb = Instance.new("TextButton", TabContainer)
    tb.Size = UDim2.new(0.9, 0, 0, 40)
    tb.Position = UDim2.new(0.05, 0, 0, (i*50)-40)
    tb.Text = tab
    tb.BackgroundColor3 = Color3.fromRGB(35, 35, 35)
    tb.TextColor3 = Color3.White
    Instance.new("UICorner", tb).CornerRadius = UDim.new(0, 6)
    
    tb.MouseButton1Click:Connect(function()
        -- Clear Content
        for _, c in pairs(ContentContainer:GetChildren()) do if c:IsA("TextButton") then c:Destroy() end end
        
        if tab == "Visuals" then
            CreateToggleBtn("Master ESP Switch", Config.ESP, "Enabled")
            CreateToggleBtn("Box ESP", Config.ESP, "Boxes")
            CreateToggleBtn("Skeleton ESP 💀", Config.ESP, "Skeletons")
            CreateToggleBtn("Name ESP", Config.ESP, "Names")
            CreateToggleBtn("Health Bar", Config.ESP, "Health")
            CreateToggleBtn("Tracers", Config.ESP, "Tracers")
        elseif tab == "Combat" then
            CreateToggleBtn("Aimbot Switch", Config.Aimbot, "Enabled")
            CreateToggleBtn("Wall Check 🧱", Config.Aimbot, "WallCheck")
            
            -- Simple FOV Slider Button
            local fovBtn = Instance.new("TextButton", ContentContainer)
            fovBtn.Size = UDim2.new(1,0,0,40)
            fovBtn.Text = "Cycle FOV (Current: "..Config.Aimbot.FOV..")"
            fovBtn.BackgroundColor3 = Color3.fromRGB(60,60,60)
            fovBtn.TextColor3 = Color3.White
            Instance.new("UICorner", fovBtn).CornerRadius = UDim.new(0,6)
            fovBtn.MouseButton1Click:Connect(function()
                Config.Aimbot.FOV = Config.Aimbot.FOV + 50
                if Config.Aimbot.FOV > 300 then Config.Aimbot.FOV = 50 end
                fovBtn.Text = "Cycle FOV (Current: "..Config.Aimbot.FOV..")"
            end)
        elseif tab == "Settings" then
            local exit = Instance.new("TextButton", ContentContainer)
            exit.Size = UDim2.new(1,0,0,40)
            exit.Text = "UNLOAD SCRIPT (PANIC)"
            exit.BackgroundColor3 = Color3.fromRGB(200,0,0)
            exit.TextColor3 = Color3.White
            Instance.new("UICorner", exit).CornerRadius = UDim.new(0,6)
            exit.MouseButton1Click:Connect(function()
                ScreenGui:Destroy()
                FOVCircle:Remove()
                for _, p in pairs(Players:GetPlayers()) do RemoveESP(p) end
            end)
        end
    end)
end

-- Start on Visuals tab
Tabs[1] = "Visuals" -- Trigger click visual manually later if needed, simplified here.