-- ============================================================================ -- MODULAR CONTROL MENU (MAIN / ESP / KHÁC) - DELTA COMPATIBLE -- ============================================================================ local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local Lighting = game:GetService("Lighting") local Workspace = game:GetService("Workspace") local CoreGui = game:GetService("CoreGui") local LocalPlayer = Players.LocalPlayer while not LocalPlayer do task.wait() LocalPlayer = Players.LocalPlayer end local Camera = Workspace.CurrentCamera Workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(function() if Workspace.CurrentCamera then Camera = Workspace.CurrentCamera end end) local function GetGuiParent() local ok, hui = pcall(function() if type(gethui) == "function" then return gethui() end return nil end) if ok and hui then return hui end local okCore, cg = pcall(function() return CoreGui end) if okCore and cg then local testOk = pcall(function() local f = Instance.new("Folder") f.Parent = cg f:Destroy() end) if testOk then return cg end end return LocalPlayer:WaitForChild("PlayerGui") end local function ProtectGui(gui) pcall(function() if syn and type(syn.protect_gui) == "function" then syn.protect_gui(gui) elseif type(protectgui) == "function" then protectgui(gui) end end) end -- Dọn UI cũ nếu thực thi lại nhiều lần for _, parent in ipairs({ GetGuiParent(), LocalPlayer:FindFirstChildOfClass("PlayerGui") }) do if parent then for _, oldName in ipairs({ "ModularControlMenu", "FlyAltitudeGui" }) do local old = parent:FindFirstChild(oldName) if old then pcall(function() old:Destroy() end) end end end end -- ============================================================================ -- 1. MODULE: StateManager -- ============================================================================ local StateManager = {} StateManager.__index = StateManager function StateManager.new() local self = setmetatable({}, StateManager) self.Config = { ScanRange = 150, ScanInterval = 0.1, DroneHeightOffset = 12, TeleKillOffset = 3.5, FlySpeed = 60, WalkSpeed = 32, AimbotSmoothness = 0.25, MaxBoxSize = Vector2.new(350, 450), } self.States = { TeleDron = false, TeleKill = false, Aimbot = false, AimMagic = false, AutoShoot = false, EspLine = false, EspBox = false, EspName = false, EspDistance = false, EspHologram = false, EspWorkspace = false, NoClip = false, FlyAir = false, Speed = false, JumpingAir = false, NightVision = false, FixLag = false, } self.Snapshots = { WalkSpeed = 16, JumpPower = 50, UseJumpPower = true, PartCollide = {}, Lighting = nil, LightingEffects = {}, FixLagApplied = false, } self._listeners = {} return self end function StateManager:GetState(name) return self.States[name] == true end function StateManager:OnStateChanged(name, callback) if not self._listeners[name] then self._listeners[name] = {} end table.insert(self._listeners[name], callback) end function StateManager:SetState(name, value) if self.States[name] == nil or self.States[name] == value then return end self.States[name] = value local list = self._listeners[name] if list then for _, cb in ipairs(list) do task.spawn(cb, value) end end end function StateManager:ToggleState(name) local nextVal = not self:GetState(name) self:SetState(name, nextVal) return nextVal end function StateManager:CaptureCharacterSnapshot(character) if not character then return end local humanoid = character:FindFirstChildOfClass("Humanoid") if humanoid then self.Snapshots.WalkSpeed = humanoid.WalkSpeed self.Snapshots.UseJumpPower = humanoid.UseJumpPower self.Snapshots.JumpPower = humanoid.UseJumpPower and humanoid.JumpPower or humanoid.JumpHeight end table.clear(self.Snapshots.PartCollide) for _, desc in ipairs(character:GetDescendants()) do if desc:IsA("BasePart") then self.Snapshots.PartCollide[desc] = desc.CanCollide end end end function StateManager:CaptureLightingSnapshot() if self.Snapshots.Lighting then return end self.Snapshots.Lighting = { Ambient = Lighting.Ambient, OutdoorAmbient = Lighting.OutdoorAmbient, Brightness = Lighting.Brightness, ClockTime = Lighting.ClockTime, FogEnd = Lighting.FogEnd, FogStart = Lighting.FogStart, FogColor = Lighting.FogColor, GlobalShadows = Lighting.GlobalShadows, EnvironmentDiffuseScale = Lighting.EnvironmentDiffuseScale, EnvironmentSpecularScale = Lighting.EnvironmentSpecularScale, } table.clear(self.Snapshots.LightingEffects) for _, child in ipairs(Lighting:GetChildren()) do if child:IsA("Atmosphere") or child:IsA("BloomEffect") or child:IsA("BlurEffect") or child:IsA("ColorCorrectionEffect") or child:IsA("SunRaysEffect") or child:IsA("DepthOfFieldEffect") then table.insert(self.Snapshots.LightingEffects, { Instance = child, Enabled = child.Enabled ~= false, }) end end end -- ============================================================================ -- 2. MODULE: TargetScanner -- ============================================================================ local TargetScanner = {} TargetScanner.__index = TargetScanner function TargetScanner.new(stateManager) local self = setmetatable({}, TargetScanner) self.StateManager = stateManager self._cachedTargets = {} self._lastScanTime = 0 return self end function TargetScanner:GetLocalRoot() local char = LocalPlayer.Character if not char or not char.Parent then return nil end local root = char:FindFirstChild("HumanoidRootPart") or char.PrimaryPart return (root and root:IsA("BasePart")) and root or nil end function TargetScanner:GetModelRoot(model) local root = model:FindFirstChild("HumanoidRootPart") or model.PrimaryPart if root and root:IsA("BasePart") then return root end for _, child in ipairs(model:GetChildren()) do if child:IsA("BasePart") then return child end end return nil end function TargetScanner:IsValidTarget(model) if not model or not model:IsA("Model") then return false, nil, nil end local localChar = LocalPlayer.Character if localChar and model == localChar then return false, nil, nil end if Players:GetPlayerFromCharacter(model) ~= nil then return false, nil, nil end local humanoid = model:FindFirstChildOfClass("Humanoid") if not humanoid or humanoid.Health <= 0 then return false, nil, nil end local root = self:GetModelRoot(model) if not root or not root.Parent then return false, nil, nil end return true, humanoid, root end function TargetScanner:Scan(forceRefresh) local now = os.clock() local interval = self.StateManager.Config.ScanInterval local originPart = self:GetLocalRoot() local originPos = originPart and originPart.Position or (Camera and Camera.CFrame.Position or Vector3.zero) local maxRange = self.StateManager.Config.ScanRange if not forceRefresh and (now - self._lastScanTime) < interval then local validNow = {} for _, entry in ipairs(self._cachedTargets) do if entry.Model and entry.Model.Parent and entry.Humanoid and entry.Humanoid.Health > 0 and entry.Root and entry.Root.Parent then local dist = (entry.Root.Position - originPos).Magnitude if dist <= maxRange then entry.Distance = dist table.insert(validNow, entry) end end end self._cachedTargets = validNow return self._cachedTargets end self._lastScanTime = now local results = {} for _, desc in ipairs(Workspace:GetDescendants()) do if desc:IsA("Model") then local ok, hum, root = self:IsValidTarget(desc) if ok and hum and root then local dist = (root.Position - originPos).Magnitude if dist <= maxRange then table.insert(results, { Model = desc, Humanoid = hum, Root = root, Distance = dist, }) end end end end table.sort(results, function(a, b) return a.Distance < b.Distance end) self._cachedTargets = results return self._cachedTargets end -- ============================================================================ -- 3. MODULE: CombatEngine -- ============================================================================ local CombatEngine = {} CombatEngine.__index = CombatEngine function CombatEngine.new(stateManager, scanner) local self = setmetatable({}, CombatEngine) self.StateManager = stateManager self.Scanner = scanner self._lockedTarget = nil self._lastAttackTime = 0 self._attackCooldown = 0.14 self._connections = {} self._droneAnchor = nil self._droneGyro = nil self:_bindInputs() return self end -- [HOOK TÙY BIẾN THEO GAME] Cắm RemoteEvent / Tool / Raycast tại đây function CombatEngine:AttackHook(target, mode, aimWorldPos) local char = LocalPlayer.Character if not char then return end local tool = char:FindFirstChildOfClass("Tool") if tool and tool:IsA("Tool") then pcall(function() tool:Activate() end) end end function CombatEngine:_canAttackNow() local now = os.clock() if (now - self._lastAttackTime) >= self._attackCooldown then self._lastAttackTime = now return true end return false end function CombatEngine:GetSmartLockedTarget(candidates) local maxRange = self.StateManager.Config.ScanRange local originPart = self.Scanner:GetLocalRoot() local originPos = originPart and originPart.Position or (Camera and Camera.CFrame.Position or Vector3.zero) if self._lockedTarget then local t = self._lockedTarget local stillValid = t.Model and t.Model.Parent ~= nil and t.Root and t.Root.Parent ~= nil and t.Humanoid and t.Humanoid.Parent ~= nil and t.Humanoid.Health > 0 and ((t.Root.Position - originPos).Magnitude <= maxRange) if stillValid then t.Distance = (t.Root.Position - originPos).Magnitude return t else self._lockedTarget = nil end end if #candidates > 0 then self._lockedTarget = candidates[1] return self._lockedTarget end return nil end function CombatEngine:_ensureDroneStabilizers(root) if not self._droneAnchor or not self._droneAnchor.Parent then local bp = Instance.new("BodyPosition") bp.Name = "TeleDronBodyPos" bp.MaxForce = Vector3.new(1e6, 1e6, 1e6) bp.P = 15000 bp.D = 1200 bp.Position = root.Position bp.Parent = root self._droneAnchor = bp elseif self._droneAnchor.Parent ~= root then self._droneAnchor.Parent = root end if not self._droneGyro or not self._droneGyro.Parent then local bg = Instance.new("BodyGyro") bg.Name = "TeleDronBodyGyro" bg.MaxForce = Vector3.new(1e5, 1e5, 1e5) bg.P = 8000 bg.D = 600 bg.CFrame = root.CFrame bg.Parent = root self._droneGyro = bg elseif self._droneGyro.Parent ~= root then self._droneGyro.Parent = root end end function CombatEngine:_clearDroneStabilizers() if self._droneAnchor then pcall(function() self._droneAnchor:Destroy() end) self._droneAnchor = nil end if self._droneGyro then pcall(function() self._droneGyro:Destroy() end) self._droneGyro = nil end end function CombatEngine:_teleportTo(pos, lookAtPos) local localRoot = self.Scanner:GetLocalRoot() if not localRoot then return end pcall(function() localRoot.AssemblyLinearVelocity = Vector3.zero localRoot.AssemblyAngularVelocity = Vector3.zero localRoot.CFrame = lookAtPos and CFrame.lookAt(pos, lookAtPos) or CFrame.new(pos) end) end function CombatEngine:_stepTeleDron(target) local localRoot = self.Scanner:GetLocalRoot() if not localRoot then return end local safeHeight = self.StateManager.Config.DroneHeightOffset local hoverPos = target.Root.Position + Vector3.new(0, safeHeight, 0) self:_ensureDroneStabilizers(localRoot) if self._droneAnchor then self._droneAnchor.Position = hoverPos end if self._droneGyro then self._droneGyro.CFrame = CFrame.lookAt(hoverPos, target.Root.Position) end pcall(function() localRoot.AssemblyLinearVelocity = Vector3.zero localRoot.CFrame = CFrame.lookAt(hoverPos, target.Root.Position) end) if self:_canAttackNow() then self:AttackHook(target, "TeleDron", target.Root.Position) end end function CombatEngine:_stepTeleKill(target) local localRoot = self.Scanner:GetLocalRoot() if not localRoot then return end local offsetDist = self.StateManager.Config.TeleKillOffset local dirFromTarget = localRoot.Position - target.Root.Position local flatDir = Vector3.new(dirFromTarget.X, 0, dirFromTarget.Z) if flatDir.Magnitude < 0.01 then local lv = -target.Root.CFrame.LookVector flatDir = Vector3.new(lv.X, 0, lv.Z) end local strikePos = target.Root.Position + flatDir.Unit * offsetDist + Vector3.new(0, 0.5, 0) self:_teleportTo(strikePos, target.Root.Position) if self:_canAttackNow() then self:AttackHook(target, "TeleKill", target.Root.Position) end end function CombatEngine:_stepAimbot(target) if not Camera then return end local aimPos = target.Root.Position + Vector3.new(0, 1.2, 0) local currentCF = Camera.CFrame local desiredCF = CFrame.lookAt(currentCF.Position, aimPos) local alpha = math.clamp(self.StateManager.Config.AimbotSmoothness, 0.05, 1) Camera.CFrame = currentCF:Lerp(desiredCF, alpha) end function CombatEngine:_triggerAimMagic() if not self.StateManager:GetState("AimMagic") then return end local candidates = self.Scanner:Scan(false) local target = self:GetSmartLockedTarget(candidates) if not target then return end local aimPos = target.Root.Position + Vector3.new(0, 1.2, 0) self:AttackHook(target, "AimMagic", aimPos) end function CombatEngine:_bindInputs() table.insert(self._connections, UserInputService.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then self:_triggerAimMagic() end end)) end function CombatEngine:Update(dt) local teleDronOn = self.StateManager:GetState("TeleDron") local teleKillOn = self.StateManager:GetState("TeleKill") local aimbotOn = self.StateManager:GetState("Aimbot") local autoShootOn = self.StateManager:GetState("AutoShoot") if not teleDronOn then self:_clearDroneStabilizers() end if not (teleDronOn or teleKillOn or aimbotOn or autoShootOn) then return end local candidates = self.Scanner:Scan(false) local target = self:GetSmartLockedTarget(candidates) if not target then return end local aimPos = target.Root.Position + Vector3.new(0, 1.2, 0) if teleDronOn then self:_stepTeleDron(target) elseif teleKillOn then self:_stepTeleKill(target) end if aimbotOn then self:_stepAimbot(target) end if autoShootOn and self:_canAttackNow() then self:AttackHook(target, "AutoShoot", aimPos) end end function CombatEngine:Destroy() self:_clearDroneStabilizers() for _, conn in ipairs(self._connections) do pcall(function() conn:Disconnect() end) end table.clear(self._connections) end -- ============================================================================ -- 4. MODULE: EspEngine -- ============================================================================ local EspEngine = {} EspEngine.__index = EspEngine local HAS_DRAWING = pcall(function() return Drawing ~= nil and type(Drawing.new) == "function" end) function EspEngine.new(stateManager, scanner) local self = setmetatable({}, EspEngine) self.StateManager = stateManager self.Scanner = scanner self._targetVisuals = {} self._workspaceHighlights = {} self._workspaceWatchConn = nil return self end function EspEngine:_newLine(thickness, color) if not HAS_DRAWING then return nil end local ok, line = pcall(function() local l = Drawing.new("Line") l.Visible = false l.Thickness = thickness l.Color = color l.Transparency = 1 return l end) return ok and line or nil end function EspEngine:_newText(size, color) if not HAS_DRAWING then return nil end local ok, txt = pcall(function() local t = Drawing.new("Text") t.Visible = false t.Size = size t.Color = color t.Center = true t.Outline = true t.Transparency = 1 return t end) return ok and txt or nil end function EspEngine:_createTargetVisual(model) local vis = { Line = self:_newLine(1.5, Color3.fromRGB(255, 85, 85)), BoxTop = self:_newLine(1.5, Color3.fromRGB(80, 220, 120)), BoxBottom = self:_newLine(1.5, Color3.fromRGB(80, 220, 120)), BoxLeft = self:_newLine(1.5, Color3.fromRGB(80, 220, 120)), BoxRight = self:_newLine(1.5, Color3.fromRGB(80, 220, 120)), NameText = self:_newText(14, Color3.fromRGB(255, 255, 255)), DistText = self:_newText(13, Color3.fromRGB(255, 220, 100)), Highlight = nil, } pcall(function() local h = Instance.new("Highlight") h.Name = "EspHologramHighlight" h.Adornee = model h.FillColor = Color3.fromRGB(255, 70, 70) h.OutlineColor = Color3.fromRGB(255, 230, 120) h.FillTransparency = 0.55 h.OutlineTransparency = 0 h.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop h.Enabled = false h.Parent = GetGuiParent() vis.Highlight = h end) self._targetVisuals[model] = vis return vis end function EspEngine:_destroyTargetVisual(model) local vis = self._targetVisuals[model] if not vis then return end for _, obj in ipairs({ vis.Line, vis.BoxTop, vis.BoxBottom, vis.BoxLeft, vis.BoxRight, vis.NameText, vis.DistText }) do if obj then pcall(function() obj.Visible = false obj:Remove() end) end end if vis.Highlight then pcall(function() vis.Highlight:Destroy() end) end self._targetVisuals[model] = nil end function EspEngine:_hideTargetVisual(vis) if vis.Line then pcall(function() vis.Line.Visible = false end) end if vis.BoxTop then pcall(function() vis.BoxTop.Visible = false end) end if vis.BoxBottom then pcall(function() vis.BoxBottom.Visible = false end) end if vis.BoxLeft then pcall(function() vis.BoxLeft.Visible = false end) end if vis.BoxRight then pcall(function() vis.BoxRight.Visible = false end) end if vis.NameText then pcall(function() vis.NameText.Visible = false end) end if vis.DistText then pcall(function() vis.DistText.Visible = false end) end if vis.Highlight then pcall(function() vis.Highlight.Enabled = false end) end end function EspEngine:_applyWorkspaceHighlight(item) if self._workspaceHighlights[item] then return end local adornee = (item:IsA("Model") or item:IsA("BasePart")) and item or item:FindFirstChildWhichIsA("BasePart", true) if not adornee then return end pcall(function() local h = Instance.new("Highlight") h.Name = "EspWorkspaceHighlight" h.Adornee = adornee h.FillColor = Color3.fromRGB(70, 185, 255) h.OutlineColor = Color3.fromRGB(180, 235, 255) h.FillTransparency = 0.5 h.OutlineTransparency = 0 h.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop h.Parent = GetGuiParent() self._workspaceHighlights[item] = h end) end function EspEngine:CleanupWorkspaceEsp() if self._workspaceWatchConn then pcall(function() self._workspaceWatchConn:Disconnect() end) self._workspaceWatchConn = nil end for item, hl in pairs(self._workspaceHighlights) do pcall(function() hl:Destroy() end) self._workspaceHighlights[item] = nil end end function EspEngine:CleanupAll() for model in pairs(self._targetVisuals) do self:_destroyTargetVisual(model) end table.clear(self._targetVisuals) self:CleanupWorkspaceEsp() end function EspEngine:_updateWorkspaceEsp() if not self.StateManager:GetState("EspWorkspace") then if next(self._workspaceHighlights) ~= nil or self._workspaceWatchConn ~= nil then self:CleanupWorkspaceEsp() end return end local itemFolder = Workspace:FindFirstChild("Item") if not itemFolder then self:CleanupWorkspaceEsp() return end for _, child in ipairs(itemFolder:GetChildren()) do self:_applyWorkspaceHighlight(child) end if not self._workspaceWatchConn then self._workspaceWatchConn = itemFolder.ChildAdded:Connect(function(child) if self.StateManager:GetState("EspWorkspace") then task.wait() self:_applyWorkspaceHighlight(child) end end) end end function EspEngine:Update() self:_updateWorkspaceEsp() local lineOn = self.StateManager:GetState("EspLine") local boxOn = self.StateManager:GetState("EspBox") local nameOn = self.StateManager:GetState("EspName") local distOn = self.StateManager:GetState("EspDistance") local holoOn = self.StateManager:GetState("EspHologram") if not (lineOn or boxOn or nameOn or distOn or holoOn) or not Camera then for model in pairs(self._targetVisuals) do self:_destroyTargetVisual(model) end return end local validTargets = self.Scanner:Scan(false) local activeMap = {} for _, entry in ipairs(validTargets) do activeMap[entry.Model] = entry end for model in pairs(self._targetVisuals) do if not activeMap[model] then self:_destroyTargetVisual(model) end end local viewportSize = Camera.ViewportSize local topCenter = Vector2.new(viewportSize.X * 0.5, 0) for _, entry in ipairs(validTargets) do local vis = self._targetVisuals[entry.Model] or self:_createTargetVisual(entry.Model) self:_hideTargetVisual(vis) if holoOn and vis.Highlight then pcall(function() vis.Highlight.Enabled = true vis.Highlight.Adornee = entry.Model end) end local cf, size = entry.Model:GetBoundingBox() local hx, hy, hz = size.X * 0.5, size.Y * 0.5, size.Z * 0.5 local corners = { cf * Vector3.new(-hx, -hy, -hz), cf * Vector3.new(-hx, -hy, hz), cf * Vector3.new(-hx, hy, -hz), cf * Vector3.new(-hx, hy, hz), cf * Vector3.new(hx, -hy, -hz), cf * Vector3.new(hx, -hy, hz), cf * Vector3.new(hx, hy, -hz), cf * Vector3.new(hx, hy, hz), } local minX, minY, maxX, maxY = math.huge, math.huge, -math.huge, -math.huge local anyInFront = false for _, cWorld in ipairs(corners) do local sp = Camera:WorldToViewportPoint(cWorld) if sp.Z > 0 then anyInFront = true minX, minY = math.min(minX, sp.X), math.min(minY, sp.Y) maxX, maxY = math.max(maxX, sp.X), math.max(maxY, sp.Y) end end local rootScreen = Camera:WorldToViewportPoint(entry.Root.Position) if not anyInFront and rootScreen.Z <= 0 then continue end local cx = anyInFront and ((minX + maxX) * 0.5) or rootScreen.X local cy = anyInFront and ((minY + maxY) * 0.5) or rootScreen.Y if lineOn and vis.Line then pcall(function() vis.Line.From = topCenter vis.Line.To = Vector2.new(cx, anyInFront and minY or cy) vis.Line.Visible = true end) end if boxOn and anyInFront and vis.BoxTop and vis.BoxBottom and vis.BoxLeft and vis.BoxRight then pcall(function() local w = math.clamp(maxX - minX, 12, self.StateManager.Config.MaxBoxSize.X) local h = math.clamp(maxY - minY, 18, self.StateManager.Config.MaxBoxSize.Y) local x0, y0, x1, y1 = cx - w * 0.5, cy - h * 0.5, cx + w * 0.5, cy + h * 0.5 local tl, tr, bl, br = Vector2.new(x0, y0), Vector2.new(x1, y0), Vector2.new(x0, y1), Vector2.new(x1, y1) vis.BoxTop.From, vis.BoxTop.To, vis.BoxTop.Visible = tl, tr, true vis.BoxBottom.From, vis.BoxBottom.To, vis.BoxBottom.Visible = bl, br, true vis.BoxLeft.From, vis.BoxLeft.To, vis.BoxLeft.Visible = tl, bl, true vis.BoxRight.From, vis.BoxRight.To, vis.BoxRight.Visible = tr, br, true end) end if nameOn and vis.NameText then pcall(function() vis.NameText.Text = tostring(entry.Model.Name) vis.NameText.Position = Vector2.new(cx, (anyInFront and minY or cy) - 18) vis.NameText.Visible = true end) end if distOn and vis.DistText then pcall(function() vis.DistText.Text = string.format("[%d studs]", math.floor(entry.Distance + 0.5)) vis.DistText.Position = Vector2.new(cx, anyInFront and (maxY + 4) or (cy + 12)) vis.DistText.Visible = true end) end end end -- ============================================================================ -- 5. MODULE: MovementAndWorld -- ============================================================================ local MovementAndWorld = {} MovementAndWorld.__index = MovementAndWorld function MovementAndWorld.new(stateManager) local self = setmetatable({}, MovementAndWorld) self.StateManager = stateManager self._connections = {} self._flyBV = nil self._flyBG = nil self._flyAscendHold = false self._flyDescendHold = false self._flyControlGui = nil self:_bindStateHandlers() self:_bindCharacterEvents() self:_bindJumpRequest() return self end function MovementAndWorld:_getHumanoidAndRoot() local char = LocalPlayer.Character if not char or not char.Parent then return nil, nil end local hum = char:FindFirstChildOfClass("Humanoid") local root = char:FindFirstChild("HumanoidRootPart") or char.PrimaryPart return hum, (root and root:IsA("BasePart") and root or nil) end function MovementAndWorld:_createFlyAltitudeControls() if self._flyControlGui and self._flyControlGui.Parent then self._flyControlGui.Enabled = true return end local gui = Instance.new("ScreenGui") gui.Name = "FlyAltitudeGui" gui.ResetOnSpawn = false gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling ProtectGui(gui) gui.Parent = GetGuiParent() local holder = Instance.new("Frame") holder.Size = UDim2.fromOffset(110, 96) holder.Position = UDim2.new(1, -130, 0.5, -48) holder.BackgroundColor3 = Color3.fromRGB(22, 25, 32) holder.BackgroundTransparency = 0.2 holder.BorderSizePixel = 0 holder.Parent = gui Instance.new("UICorner", holder).CornerRadius = UDim.new(0, 8) local upBtn = Instance.new("TextButton") upBtn.Size = UDim2.new(1, -12, 0, 38) upBtn.Position = UDim2.fromOffset(6, 6) upBtn.BackgroundColor3 = Color3.fromRGB(48, 130, 220) upBtn.TextColor3 = Color3.new(1, 1, 1) upBtn.Font = Enum.Font.GothamBold upBtn.TextSize = 13 upBtn.Text = "▲ Lên cao" upBtn.Parent = holder Instance.new("UICorner", upBtn).CornerRadius = UDim.new(0, 6) local downBtn = Instance.new("TextButton") downBtn.Size = UDim2.new(1, -12, 0, 38) downBtn.Position = UDim2.fromOffset(6, 52) downBtn.BackgroundColor3 = Color3.fromRGB(205, 85, 70) downBtn.TextColor3 = Color3.new(1, 1, 1) downBtn.Font = Enum.Font.GothamBold downBtn.TextSize = 13 downBtn.Text = "▼ Hạ thấp" downBtn.Parent = holder Instance.new("UICorner", downBtn).CornerRadius = UDim.new(0, 6) upBtn.MouseButton1Down:Connect(function() self._flyAscendHold = true end) upBtn.MouseButton1Up:Connect(function() self._flyAscendHold = false end) upBtn.MouseLeave:Connect(function() self._flyAscendHold = false end) downBtn.MouseButton1Down:Connect(function() self._flyDescendHold = true end) downBtn.MouseButton1Up:Connect(function() self._flyDescendHold = false end) downBtn.MouseLeave:Connect(function() self._flyDescendHold = false end) self._flyControlGui = gui end function MovementAndWorld:_hideFlyAltitudeControls() self._flyAscendHold = false self._flyDescendHold = false if self._flyControlGui then pcall(function() self._flyControlGui.Enabled = false end) end end function MovementAndWorld:_enableFly() local _, root = self:_getHumanoidAndRoot() if not root then return end self:_createFlyAltitudeControls() if not self._flyBV or not self._flyBV.Parent then pcall(function() local bv = Instance.new("BodyVelocity") bv.Name = "FlyAirVelocity" bv.MaxForce = Vector3.new(1e6, 1e6, 1e6) bv.Velocity = Vector3.zero bv.Parent = root self._flyBV = bv end) end if not self._flyBG or not self._flyBG.Parent then pcall(function() local bg = Instance.new("BodyGyro") bg.Name = "FlyAirGyro" bg.MaxForce = Vector3.new(1e5, 1e5, 1e5) bg.P = 6000 bg.D = 500 bg.CFrame = Camera and Camera.CFrame or root.CFrame bg.Parent = root self._flyBG = bg end) end end function MovementAndWorld:_disableFly() self:_hideFlyAltitudeControls() if self._flyBV then pcall(function() self._flyBV:Destroy() end); self._flyBV = nil end if self._flyBG then pcall(function() self._flyBG:Destroy() end); self._flyBG = nil end end function MovementAndWorld:_applySpeed() local hum = select(1, self:_getHumanoidAndRoot()) if not hum then return end pcall(function() hum.WalkSpeed = self.StateManager:GetState("Speed") and self.StateManager.Config.WalkSpeed or self.StateManager.Snapshots.WalkSpeed end) end function MovementAndWorld:_applyNoClip(enabled) local char = LocalPlayer.Character if not char then return end if enabled then for _, desc in ipairs(char:GetDescendants()) do if desc:IsA("BasePart") then if self.StateManager.Snapshots.PartCollide[desc] == nil then self.StateManager.Snapshots.PartCollide[desc] = desc.CanCollide end pcall(function() desc.CanCollide = false end) end end else for part, origCollide in pairs(self.StateManager.Snapshots.PartCollide) do if part and part.Parent then pcall(function() part.CanCollide = origCollide end) end end table.clear(self.StateManager.Snapshots.PartCollide) end end function MovementAndWorld:_applyNightVision(enabled) if enabled then self.StateManager:CaptureLightingSnapshot() pcall(function() Lighting.Ambient = Color3.fromRGB(220, 220, 220) Lighting.OutdoorAmbient = Color3.fromRGB(220, 220, 220) Lighting.Brightness = 2.5 Lighting.ClockTime = 14 Lighting.FogStart = 1e6 Lighting.FogEnd = 1e6 Lighting.GlobalShadows = false Lighting.EnvironmentDiffuseScale = 0 Lighting.EnvironmentSpecularScale = 0 end) for _, item in ipairs(self.StateManager.Snapshots.LightingEffects) do if item.Instance and item.Instance.Parent then pcall(function() if item.Instance:IsA("Atmosphere") then item.Instance.Density = 0 elseif item.Instance.Enabled ~= nil then item.Instance.Enabled = false end end) end end else local snap = self.StateManager.Snapshots.Lighting if snap then pcall(function() Lighting.Ambient = snap.Ambient Lighting.OutdoorAmbient = snap.OutdoorAmbient Lighting.Brightness = snap.Brightness Lighting.ClockTime = snap.ClockTime Lighting.FogStart = snap.FogStart Lighting.FogEnd = snap.FogEnd Lighting.FogColor = snap.FogColor Lighting.GlobalShadows = snap.GlobalShadows Lighting.EnvironmentDiffuseScale = snap.EnvironmentDiffuseScale Lighting.EnvironmentSpecularScale = snap.EnvironmentSpecularScale end) end for _, item in ipairs(self.StateManager.Snapshots.LightingEffects) do if item.Instance and item.Instance.Parent then pcall(function() if item.Instance:IsA("Atmosphere") then item.Instance.Density = 0.3 elseif item.Instance.Enabled ~= nil then item.Instance.Enabled = item.Enabled end end) end end self.StateManager.Snapshots.Lighting = nil end end function MovementAndWorld:_applyFixLag(enabled) if not enabled or self.StateManager.Snapshots.FixLagApplied then return end self.StateManager.Snapshots.FixLagApplied = true pcall(function() Lighting.GlobalShadows = false end) for _, desc in ipairs(Workspace:GetDescendants()) do if desc:IsA("ParticleEmitter") or desc:IsA("Trail") or desc:IsA("Beam") or desc:IsA("Fire") or desc:IsA("Smoke") then pcall(function() desc.Enabled = false end) elseif desc:IsA("BasePart") then pcall(function() desc.CastShadow = false if desc:IsA("MeshPart") then desc.TextureID = "" end end) elseif desc:IsA("Decal") or desc:IsA("Texture") then pcall(function() desc.Transparency = 1 end) end end end function MovementAndWorld:_bindJumpRequest() table.insert(self._connections, UserInputService.JumpRequest:Connect(function() if not self.StateManager:GetState("JumpingAir") then return end local hum = select(1, self:_getHumanoidAndRoot()) if hum and hum.Health > 0 then pcall(function() hum:ChangeState(Enum.HumanoidStateType.Jumping) end) end end)) end function MovementAndWorld:_bindCharacterEvents() local function onCharAdded(char) self.StateManager:CaptureCharacterSnapshot(char) task.wait(0.1) if self.StateManager:GetState("Speed") then self:_applySpeed() end if self.StateManager:GetState("FlyAir") then self:_enableFly() end if self.StateManager:GetState("NoClip") then self:_applyNoClip(true) end end if LocalPlayer.Character then onCharAdded(LocalPlayer.Character) end table.insert(self._connections, LocalPlayer.CharacterAdded:Connect(onCharAdded)) end function MovementAndWorld:_bindStateHandlers() self.StateManager:OnStateChanged("NoClip", function(v) self:_applyNoClip(v) end) self.StateManager:OnStateChanged("FlyAir", function(v) if v then self:_enableFly() else self:_disableFly() end end) self.StateManager:OnStateChanged("Speed", function() self:_applySpeed() end) self.StateManager:OnStateChanged("NightVision", function(v) self:_applyNightVision(v) end) self.StateManager:OnStateChanged("FixLag", function(v) if v then self:_applyFixLag(true) end end) end function MovementAndWorld:Update(dt) if self.StateManager:GetState("NoClip") then self:_applyNoClip(true) end if self.StateManager:GetState("Speed") then local hum = select(1, self:_getHumanoidAndRoot()) if hum and hum.WalkSpeed ~= self.StateManager.Config.WalkSpeed then pcall(function() hum.WalkSpeed = self.StateManager.Config.WalkSpeed end) end end if self.StateManager:GetState("FlyAir") then local hum, root = self:_getHumanoidAndRoot() if hum and root then if not self._flyBV or not self._flyBV.Parent then self:_enableFly() end local speed = self.StateManager.Config.FlySpeed local moveDir = hum.MoveDirection local horizVel = Vector3.new(moveDir.X, 0, moveDir.Z) horizVel = (horizVel.Magnitude > 0.01) and (horizVel.Unit * speed) or Vector3.zero local vertSpeed = 0 if self._flyAscendHold or UserInputService:IsKeyDown(Enum.KeyCode.Space) or UserInputService:IsKeyDown(Enum.KeyCode.E) then vertSpeed = speed * 0.75 elseif self._flyDescendHold or UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) or UserInputService:IsKeyDown(Enum.KeyCode.Q) then vertSpeed = -speed * 0.75 end if self._flyBV then pcall(function() self._flyBV.Velocity = Vector3.new(horizVel.X, vertSpeed, horizVel.Z) end) end if self._flyBG and Camera then pcall(function() self._flyBG.CFrame = CFrame.lookAt(root.Position, root.Position + Camera.CFrame.LookVector) end) end end end end function MovementAndWorld:Destroy() self:_disableFly() self:_applyNoClip(false) for _, conn in ipairs(self._connections) do pcall(function() conn:Disconnect() end) end table.clear(self._connections) if self._flyControlGui then pcall(function() self._flyControlGui:Destroy() end); self._flyControlGui = nil end end -- ============================================================================ -- 6. MODULE: UIController -- ============================================================================ local UIController = {} UIController.__index = UIController function UIController.new(stateManager) local self = setmetatable({}, UIController) self.StateManager = stateManager self._gui = nil self._mainFrame = nil self._bodyFrame = nil self._tabFrames = {} self._tabButtons = {} self._toggleButtons = {} self._collapsed = false self:_buildUI() self:_switchTab("Main") return self end function UIController:_refreshToggleVisual(key) local btn = self._toggleButtons[key] if not btn then return end local active = self.StateManager:GetState(key) btn.Text = active and "ON" or "OFF" btn.BackgroundColor3 = active and Color3.fromRGB(45, 175, 105) or Color3.fromRGB(65, 70, 82) end function UIController:_createToggleRow(parent, labelText, stateKey, order) local row = Instance.new("Frame") row.Size = UDim2.new(1, -8, 0, 34) row.BackgroundColor3 = Color3.fromRGB(32, 36, 46) row.BorderSizePixel = 0 row.LayoutOrder = order row.Parent = parent Instance.new("UICorner", row).CornerRadius = UDim.new(0, 6) local lbl = Instance.new("TextLabel") lbl.Size = UDim2.new(1, -76, 1, 0) lbl.Position = UDim2.fromOffset(10, 0) lbl.BackgroundTransparency = 1 lbl.TextXAlignment = Enum.TextXAlignment.Left lbl.Font = Enum.Font.GothamMedium lbl.TextSize = 13 lbl.TextColor3 = Color3.fromRGB(235, 240, 248) lbl.Text = labelText lbl.Parent = row local btn = Instance.new("TextButton") btn.Size = UDim2.fromOffset(58, 24) btn.Position = UDim2.new(1, -66, 0.5, -12) btn.BorderSizePixel = 0 btn.Font = Enum.Font.GothamBold btn.TextSize = 12 btn.TextColor3 = Color3.new(1, 1, 1) btn.Parent = row Instance.new("UICorner", btn).CornerRadius = UDim.new(0, 5) self._toggleButtons[stateKey] = btn self:_refreshToggleVisual(stateKey) btn.MouseButton1Click:Connect(function() self.StateManager:ToggleState(stateKey) self:_refreshToggleVisual(stateKey) end) self.StateManager:OnStateChanged(stateKey, function() self:_refreshToggleVisual(stateKey) end) end function UIController:_createNumberRow(parent, labelText, configKey, minVal, maxVal, order) local row = Instance.new("Frame") row.Size = UDim2.new(1, -8, 0, 34) row.BackgroundColor3 = Color3.fromRGB(32, 36, 46) row.BorderSizePixel = 0 row.LayoutOrder = order row.Parent = parent Instance.new("UICorner", row).CornerRadius = UDim.new(0, 6) local lbl = Instance.new("TextLabel") lbl.Size = UDim2.new(1, -86, 1, 0) lbl.Position = UDim2.fromOffset(10, 0) lbl.BackgroundTransparency = 1 lbl.TextXAlignment = Enum.TextXAlignment.Left lbl.Font = Enum.Font.GothamMedium lbl.TextSize = 13 lbl.TextColor3 = Color3.fromRGB(205, 220, 245) lbl.Text = labelText lbl.Parent = row local box = Instance.new("TextBox") box.Size = UDim2.fromOffset(68, 24) box.Position = UDim2.new(1, -76, 0.5, -12) box.BackgroundColor3 = Color3.fromRGB(20, 23, 30) box.TextColor3 = Color3.fromRGB(130, 215, 255) box.Font = Enum.Font.GothamBold box.TextSize = 12 box.ClearTextOnFocus = false box.Text = tostring(self.StateManager.Config[configKey]) box.Parent = row Instance.new("UICorner", box).CornerRadius = UDim.new(0, 5) box.FocusLost:Connect(function() local parsed = tonumber(box.Text) if parsed then local clamped = math.clamp(parsed, minVal, maxVal) self.StateManager.Config[configKey] = clamped box.Text = tostring(clamped) else box.Text = tostring(self.StateManager.Config[configKey]) end end) end function UIController:_makeDraggable(frame, dragHandle) local dragging = false local dragStart = Vector2.zero local startPos = UDim2.new() dragHandle.InputBegan:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then dragging = true dragStart = Vector2.new(input.Position.X, input.Position.Y) startPos = frame.Position end end) UserInputService.InputChanged:Connect(function(input) if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then local delta = Vector2.new(input.Position.X, input.Position.Y) - dragStart frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y) end end) UserInputService.InputEnded:Connect(function(input) if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then dragging = false end end) end function UIController:_switchTab(tabName) for name, scroll in pairs(self._tabFrames) do scroll.Visible = (name == tabName) end for name, btn in pairs(self._tabButtons) do local active = (name == tabName) btn.BackgroundColor3 = active and Color3.fromRGB(58, 125, 225) or Color3.fromRGB(36, 40, 52) btn.TextColor3 = active and Color3.new(1, 1, 1) or Color3.fromRGB(175, 185, 200) end end function UIController:_buildTabContent(tabName) local scroll = Instance.new("ScrollingFrame") scroll.Name = tabName .. "Tab" scroll.Size = UDim2.new(1, -12, 1, -44) scroll.Position = UDim2.fromOffset(6, 38) scroll.BackgroundTransparency = 1 scroll.ScrollBarThickness = 4 scroll.AutomaticCanvasSize = Enum.AutomaticSize.Y scroll.CanvasSize = UDim2.fromOffset(0, 0) scroll.Visible = false scroll.Parent = self._bodyFrame local layout = Instance.new("UIListLayout") layout.Padding = UDim.new(0, 6) layout.SortOrder = Enum.SortOrder.LayoutOrder layout.Parent = scroll return scroll end function UIController:_buildUI() local gui = Instance.new("ScreenGui") gui.Name = "ModularControlMenu" gui.ResetOnSpawn = false gui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling ProtectGui(gui) gui.Parent = GetGuiParent() self._gui = gui local mainFrame = Instance.new("Frame") mainFrame.Size = UDim2.fromOffset(290, 390) mainFrame.Position = UDim2.fromOffset(24, 90) mainFrame.BackgroundColor3 = Color3.fromRGB(20, 23, 30) mainFrame.BorderSizePixel = 0 mainFrame.Parent = gui self._mainFrame = mainFrame Instance.new("UICorner", mainFrame).CornerRadius = UDim.new(0, 8) local header = Instance.new("Frame") header.Size = UDim2.new(1, 0, 0, 36) header.BackgroundColor3 = Color3.fromRGB(28, 32, 42) header.BorderSizePixel = 0 header.Parent = mainFrame Instance.new("UICorner", header).CornerRadius = UDim.new(0, 8) local title = Instance.new("TextLabel") title.Size = UDim2.new(1, -46, 1, 0) title.Position = UDim2.fromOffset(12, 0) title.BackgroundTransparency = 1 title.TextXAlignment = Enum.TextXAlignment.Left title.Font = Enum.Font.GothamBold title.TextSize = 14 title.TextColor3 = Color3.new(1, 1, 1) title.Text = "CONTROL MENU (150m)" title.Parent = header local collapseBtn = Instance.new("TextButton") collapseBtn.Size = UDim2.fromOffset(28, 24) collapseBtn.Position = UDim2.new(1, -34, 0.5, -12) collapseBtn.BackgroundColor3 = Color3.fromRGB(48, 54, 68) collapseBtn.TextColor3 = Color3.new(1, 1, 1) collapseBtn.Font = Enum.Font.GothamBold collapseBtn.TextSize = 14 collapseBtn.Text = "-" collapseBtn.Parent = header Instance.new("UICorner", collapseBtn).CornerRadius = UDim.new(0, 5) self:_makeDraggable(mainFrame, header) local bodyFrame = Instance.new("Frame") bodyFrame.Size = UDim2.new(1, 0, 1, -36) bodyFrame.Position = UDim2.fromOffset(0, 36) bodyFrame.BackgroundTransparency = 1 bodyFrame.Parent = mainFrame self._bodyFrame = bodyFrame collapseBtn.MouseButton1Click:Connect(function() self._collapsed = not self._collapsed bodyFrame.Visible = not self._collapsed collapseBtn.Text = self._collapsed and "+" or "-" mainFrame.Size = self._collapsed and UDim2.fromOffset(290, 36) or UDim2.fromOffset(290, 390) end) local tabBar = Instance.new("Frame") tabBar.Size = UDim2.new(1, -12, 0, 28) tabBar.Position = UDim2.fromOffset(6, 6) tabBar.BackgroundTransparency = 1 tabBar.Parent = bodyFrame local tabNames = { "Main", "Esp", "Khác" } for idx, tabName in ipairs(tabNames) do local tBtn = Instance.new("TextButton") tBtn.Size = UDim2.new(1 / #tabNames, -4, 1, 0) tBtn.Position = UDim2.new((idx - 1) / #tabNames, 2, 0, 0) tBtn.BorderSizePixel = 0 tBtn.Font = Enum.Font.GothamBold tBtn.TextSize = 12 tBtn.Text = tabName tBtn.Parent = tabBar Instance.new("UICorner", tBtn).CornerRadius = UDim.new(0, 5) self._tabButtons[tabName] = tBtn self._tabFrames[tabName] = self:_buildTabContent(tabName) tBtn.MouseButton1Click:Connect(function() self:_switchTab(tabName) end) end local mainScroll = self._tabFrames["Main"] self:_createToggleRow(mainScroll, "Tele Dron", "TeleDron", 1) self:_createNumberRow(mainScroll, "Độ cao Dron (studs)", "DroneHeightOffset", 3, 60, 2) self:_createToggleRow(mainScroll, "Tele Kill", "TeleKill", 3) self:_createToggleRow(mainScroll, "Aimbot", "Aimbot", 4) self:_createToggleRow(mainScroll, "Aim Magic", "AimMagic", 5) self:_createToggleRow(mainScroll, "Auto Bắn", "AutoShoot", 6) local espScroll = self._tabFrames["Esp"] self:_createToggleRow(espScroll, "Esp Line", "EspLine", 1) self:_createToggleRow(espScroll, "Esp Box", "EspBox", 2) self:_createToggleRow(espScroll, "Esp Name", "EspName", 3) self:_createToggleRow(espScroll, "Esp Distance", "EspDistance", 4) self:_createToggleRow(espScroll, "Esp Hologram", "EspHologram", 5) self:_createToggleRow(espScroll, "Esp Workspace", "EspWorkspace", 6) local otherScroll = self._tabFrames["Khác"] self:_createToggleRow(otherScroll, "No Clip", "NoClip", 1) self:_createToggleRow(otherScroll, "Fly Air", "FlyAir", 2) self:_createNumberRow(otherScroll, "Fly Speed", "FlySpeed", 5, 250, 3) self:_createToggleRow(otherScroll, "Speed", "Speed", 4) self:_createNumberRow(otherScroll, "Walk Speed", "WalkSpeed", 8, 200, 5) self:_createToggleRow(otherScroll, "Jumping Air", "JumpingAir", 6) self:_createToggleRow(otherScroll, "Night Vision", "NightVision", 7) self:_createToggleRow(otherScroll, "Fix Lag", "FixLag", 8) end function UIController:Destroy() if self._gui then pcall(function() self._gui:Destroy() end) self._gui = nil end end -- ============================================================================ -- KHỞI TẠO & VÒNG LẶP CHÍNH -- ============================================================================ local stateManager = StateManager.new() local scanner = TargetScanner.new(stateManager) local combatEngine = CombatEngine.new(stateManager, scanner) local espEngine = EspEngine.new(stateManager, scanner) local movementWorld = MovementAndWorld.new(stateManager) local uiController = UIController.new(stateManager) for _, espKey in ipairs({ "EspLine", "EspBox", "EspName", "EspDistance", "EspHologram" }) do stateManager:OnStateChanged(espKey, function(enabled) if not enabled then espEngine:Update() end end) end stateManager:OnStateChanged("EspWorkspace", function(enabled) if not enabled then espEngine:CleanupWorkspaceEsp() end end) local renderConn = RunService.RenderStepped:Connect(function(dt) pcall(function() combatEngine:Update(dt) end) pcall(function() espEngine:Update() end) pcall(function() movementWorld:Update(dt) end) end) LocalPlayer.AncestryChanged:Connect(function(_, parent) if not parent then pcall(function() renderConn:Disconnect() end) pcall(function() combatEngine:Destroy() end) pcall(function() espEngine:CleanupAll() end) pcall(function() movementWorld:Destroy() end) pcall(function() uiController:Destroy() end) end end)