--[[ ControlMenu.lua — LocalScript (đặt trong StarterPlayer > StarterPlayerScripts) Menu 3 tab: Main / Esp / Khác. Phạm vi mặc định 150 studs. Kiến trúc (tất cả trong 1 file, tách module rõ ràng): Maid : dọn dẹp kết nối/Instance (chống rò rỉ khi bật/tắt nhiều lần) StateManager : trạng thái, cấu hình, Snapshot giá trị gốc, đăng ký tính năng TargetScanner : quét + cache mục tiêu hợp lệ (Model có Humanoid, không phải người chơi) CombatEngine : Tele Dron / Tele Kill / Aimbot / Aim Magic / Auto Bắn (+ AttackHook) EspEngine : Line / Box / Name / Distance / Hologram / Workspace MovementAndWorld: Fly Dron / No Clip / Fly Air / Speed / Jumping Air / Night Vision / Fix Lag UIController : giao diện kéo thả, thu gọn, 3 tab, sắp xếp lại chức năng CÁCH CẮM CƠ CHẾ TẤN CÔNG CỦA GAME: xem phần "CombatEngine" (AttackHook, MagicHook, RedirectDirection). ]] ---------------------------------------------------------------------- -- Dịch vụ & tiện ích chung ---------------------------------------------------------------------- local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local Workspace = game:GetService("Workspace") local Lighting = game:GetService("Lighting") local TweenService = game:GetService("TweenService") local LP = Players.LocalPlayer local PlayerGui = LP:WaitForChild("PlayerGui") -- Chạy lại script: gỡ bản cũ trước để không nhân đôi kết nối if _G.__CM_Unload then pcall(_G.__CM_Unload) end -- Lấy (Character, Humanoid, HumanoidRootPart) còn sống của mình local function getCharParts() local c = LP.Character if not c then return end local h = c:FindFirstChildOfClass("Humanoid") local r = c:FindFirstChild("HumanoidRootPart") if h and r and r:IsA("BasePart") and h.Health > 0 then return c, h, r end end ---------------------------------------------------------------------- -- Maid: dọn dẹp tập trung ---------------------------------------------------------------------- local Maid = {} Maid.__index = Maid function Maid.new() return setmetatable({ items = {} }, Maid) end function Maid:Add(item) table.insert(self.items, item) return item end function Maid:Clean() local items = self.items self.items = {} for _, it in ipairs(items) do local t = typeof(it) if t == "RBXScriptConnection" then it:Disconnect() elseif t == "Instance" then pcall(it.Destroy, it) elseif t == "function" then pcall(it) elseif t == "table" and it.Destroy then pcall(it.Destroy, it) end end end ---------------------------------------------------------------------- -- StateManager ---------------------------------------------------------------------- local SM = { Enabled = {}, Handlers = {}, Maids = {}, Changed = Instance.new("BindableEvent"), -- (featureName, isOn) ConfigChanged = Instance.new("BindableEvent"), -- (key, value) Config = { ScanRange = 150, -- bán kính quét (studs) ScanInterval = 0.1, -- chu kỳ quét/cache (giây) DroneHeightOffset = 12, -- độ cao an toàn của Tele Dron so với mục tiêu KillStandOff = 4, -- khoảng cách đứng quanh mục tiêu khi Tele Kill AttackInterval = 0.12, -- giãn cách giữa 2 lần gọi AttackHook AimSmooth = 14, -- độ mượt Aimbot (lớn = bám nhanh hơn) FlySpeed = 50, WalkSpeed = 50, -- giá trị WalkSpeed khi bật Speed FlyDronHeight = 6, -- độ cao cố định của Fly Dron (mặc định 6) }, Limits = { ScanRange = {20, 500}, DroneHeightOffset = {3, 60}, KillStandOff = {1, 15}, AttackInterval = {0.03, 2}, AimSmooth = {2, 60}, FlySpeed = {5, 300}, WalkSpeed = {0, 300}, FlyDronHeight = {2, 100}, ScanInterval = {0.05, 1}, }, } function SM.GetMaid(name) local m = SM.Maids[name] if not m then m = Maid.new() SM.Maids[name] = m end return m end -- def = { On = fn, Off = fn, Group = "tên nhóm loại trừ lẫn nhau" } function SM.Register(name, def) SM.Handlers[name] = def end function SM.IsOn(name) return SM.Enabled[name] == true end function SM.Set(name, value) value = value and true or false local def = SM.Handlers[name] if not def or SM.IsOn(name) == value then return end if value and def.Group then -- tắt các tính năng cùng nhóm (tránh tranh chấp CFrame/velocity) for other, d in pairs(SM.Handlers) do if other ~= name and d.Group == def.Group and SM.IsOn(other) then SM.Set(other, false) end end end SM.Enabled[name] = value if value then local ok, err = pcall(def.On) if not ok then warn("[Menu] Lỗi bật " .. name .. ": " .. tostring(err)) SM.Enabled[name] = false if def.Off then pcall(def.Off) end SM.GetMaid(name):Clean() end else if def.Off then pcall(def.Off) end SM.GetMaid(name):Clean() -- luôn ngắt sạch mọi kết nối của tính năng end SM.Changed:Fire(name, SM.IsOn(name)) end function SM.Toggle(name) SM.Set(name, not SM.IsOn(name)) end function SM.SetConfig(key, v) if type(v) ~= "number" or v ~= v then return SM.Config[key] end local lim = SM.Limits[key] if lim then v = math.clamp(v, lim[1], lim[2]) end SM.Config[key] = v SM.ConfigChanged:Fire(key, v) return v end -- Snapshot: lưu giá trị gốc TRƯỚC khi sửa, khôi phục khi tắt SM.Snapshot = { tags = {} } function SM.Snapshot.Capture(tag, inst, prop) local t = SM.Snapshot.tags[tag] if not t then t = { list = {}, seen = setmetatable({}, { __mode = "k" }) } SM.Snapshot.tags[tag] = t end local s = t.seen[inst] if not s then s = {} t.seen[inst] = s end if s[prop] then return end -- chỉ lưu lần đầu = giá trị gốc thật sự local ok, val = pcall(function() return inst[prop] end) if ok then s[prop] = true table.insert(t.list, { inst, prop, val }) end end function SM.Snapshot.Restore(tag) local t = SM.Snapshot.tags[tag] if not t then return end SM.Snapshot.tags[tag] = nil for i = #t.list, 1, -1 do local r = t.list[i] if r[1]:IsDescendantOf(game) then pcall(function() r[1][r[2]] = r[3] end) end end end ---------------------------------------------------------------------- -- TargetScanner ---------------------------------------------------------------------- local Scanner = { Users = {}, Count = 0, Candidates = {}, List = {}, Maid = Maid.new() } local function getTargetRoot(model) local r = model:FindFirstChild("HumanoidRootPart") if r and r:IsA("BasePart") then return r end local p = model.PrimaryPart if p and p:IsA("BasePart") then return p end end -- Hợp lệ: Model sống, không phải nhân vật của mình, không phải người chơi khác function Scanner.IsValid(model, hum) if not model.Parent or hum.Parent ~= model or hum.Health <= 0 then return false end local mine = LP.Character if mine and (model == mine or model:IsDescendantOf(mine)) then return false end if Players:GetPlayerFromCharacter(model) then return false end return true end -- Kiểm tra "còn sống & còn trong tầm" theo thời gian thực (dùng cho khóa mục tiêu) function Scanner.IsLive(entry) local m, h, r = entry.Model, entry.Humanoid, entry.Root if not (m.Parent and h.Parent == m and h.Health > 0 and r.Parent) then return false end local _, _, myRoot = getCharParts() if not myRoot then return false end return (r.Position - myRoot.Position).Magnitude <= SM.Config.ScanRange end local function registerInstance(inst) if inst:IsA("Humanoid") then local m = inst.Parent if m and m:IsA("Model") then Scanner.Candidates[m] = inst end end end function Scanner.Refresh() local c, _, myRoot = getCharParts() local list = {} if myRoot then local myPos, range = myRoot.Position, SM.Config.ScanRange for model, hum in pairs(Scanner.Candidates) do if not model:IsDescendantOf(Workspace) then Scanner.Candidates[model] = nil elseif Scanner.IsValid(model, hum) then local root = getTargetRoot(model) if root then local d = (root.Position - myPos).Magnitude if d <= range then table.insert(list, { Model = model, Humanoid = hum, Root = root, Distance = d, Score = d }) end end end end table.sort(list, function(a, b) return a.Distance < b.Distance end) -- Khả năng tiếp cận: phạt điểm nếu bị vật cản che (chỉ kiểm tra 8 mục tiêu gần nhất) local params = RaycastParams.new() params.FilterType = Enum.RaycastFilterType.Exclude for i = 1, math.min(8, #list) do local e = list[i] params.FilterDescendantsInstances = { c, e.Model } e.Blocked = Workspace:Raycast(myPos, e.Root.Position - myPos, params) ~= nil if e.Blocked then e.Score = e.Distance + 25 end end table.sort(list, function(a, b) return a.Score < b.Score end) end Scanner.List = list end function Scanner.GetTargets() return Scanner.List end function Scanner.Start() local m = Scanner.Maid local token = { stop = false } m:Add(function() token.stop = true end) m:Add(Workspace.DescendantAdded:Connect(registerInstance)) m:Add(Workspace.DescendantRemoving:Connect(function(inst) if inst:IsA("Humanoid") and inst.Parent then Scanner.Candidates[inst.Parent] = nil end end)) task.spawn(function() -- quét ban đầu chia nhỏ để không giật local n = 0 for _, d in ipairs(Workspace:GetDescendants()) do if token.stop then return end registerInstance(d) n += 1 if n % 1500 == 0 then task.wait() end end end) local acc = 0 m:Add(RunService.Heartbeat:Connect(function(dt) acc += dt if acc >= SM.Config.ScanInterval then acc = 0 Scanner.Refresh() end end)) end function Scanner.Stop() Scanner.Maid:Clean() Scanner.Candidates = {} Scanner.List = {} end -- Tính năng nào cần dữ liệu thì Acquire, không cần nữa thì Release => không quét vô ích function Scanner.Acquire(owner) if Scanner.Users[owner] then return end Scanner.Users[owner] = true Scanner.Count += 1 if Scanner.Count == 1 then Scanner.Start() end end function Scanner.Release(owner) if not Scanner.Users[owner] then return end Scanner.Users[owner] = nil Scanner.Count -= 1 if Scanner.Count <= 0 then Scanner.Count = 0 Scanner.Stop() end end ---------------------------------------------------------------------- -- CombatEngine ---------------------------------------------------------------------- local Combat = { Locks = {}, LastAttack = {} } --[[ ============ CẮM CƠ CHẾ TẤN CÔNG CỦA GAME TẠI ĐÂY ============ AttackHook(target, mode) target = { Model, Humanoid, Root, Distance } (mục tiêu đang khóa) mode = "Drone" | "Kill" | "Auto" Mặc định: kích hoạt Tool đang cầm (Tool:Activate()). Nếu game dùng RemoteEvent, hãy sửa, ví dụ: game.ReplicatedStorage.Remotes.Attack:FireServer(target.Model, target.Root.Position) ]] function Combat.AttackHook(target, mode) local char = LP.Character local tool = char and char:FindFirstChildOfClass("Tool") if tool then tool:Activate() end end --[[ Aim Magic: hàm được gọi khi người chơi thực hiện thao tác bắn. aimPoint = vị trí nên nhắm (Vector3). KHÔNG đụng tới Camera. Cắm vào game: gửi aimPoint cho remote bắn, hoặc dùng Combat.RedirectDirection trong đoạn code raycast/bắn của chính game để đổi hướng đạn. ]] function Combat.MagicHook(target, aimPoint) end function Combat.GetAimPart(entry) local head = entry.Model:FindFirstChild("Head") if head and head:IsA("BasePart") then return head end return entry.Root end -- Khóa mục tiêu tạm thời: giữ mục tiêu cũ tới khi chết/biến mất/ra ngoài tầm rồi mới chuyển local function acquire(owner) local lock = Combat.Locks[owner] if lock and Scanner.IsLive(lock) then return lock end for _, e in ipairs(Scanner.GetTargets()) do if Scanner.IsLive(e) then Combat.Locks[owner] = e return e end end Combat.Locks[owner] = nil end local function attack(owner, entry, mode) local now = os.clock() if now - (Combat.LastAttack[owner] or 0) < SM.Config.AttackInterval then return end Combat.LastAttack[owner] = now local ok, err = pcall(Combat.AttackHook, entry, mode) if not ok then warn("[Menu] AttackHook lỗi: " .. tostring(err)) end end function Combat.RedirectDirection(origin, dir) if SM.IsOn("AimMagic") then local e = acquire("AimMagic") if e then local part = Combat.GetAimPart(e) local v = part.Position - origin if v.Magnitude > 0.01 then return v.Unit end end end return dir end local function zeroVelocity(root) root.AssemblyLinearVelocity = Vector3.zero root.AssemblyAngularVelocity = Vector3.zero end -- Tele Dron: lơ lửng phía trên mục tiêu, giữ vị trí, tấn công hướng xuống SM.Register("TeleDron", { Group = "Move", On = function() Scanner.Acquire("TeleDron") SM.GetMaid("TeleDron"):Add(RunService.Heartbeat:Connect(function() local _, _, root = getCharParts() if not root then return end local e = acquire("TeleDron") if not e then return end local tpos = e.Root.Position local goal = tpos + Vector3.new(0, SM.Config.DroneHeightOffset, 0) root.CFrame = CFrame.lookAt(goal, tpos, Vector3.zAxis) -- nhìn xuống mục tiêu zeroVelocity(root) -- triệt tiêu lực rơi / đẩy lùi attack("TeleDron", e, "Drone") end)) end, Off = function() Scanner.Release("TeleDron") Combat.Locks.TeleDron = nil end, }) -- Tele Kill: dịch chuyển sát mục tiêu gần nhất, đánh, tự chuyển mục tiêu khi hạ gục SM.Register("TeleKill", { Group = "Move", On = function() Scanner.Acquire("TeleKill") SM.GetMaid("TeleKill"):Add(RunService.Heartbeat:Connect(function() local _, _, root = getCharParts() if not root then return end local e = acquire("TeleKill") if not e then return end local tpos = e.Root.Position local away = Vector3.new(root.Position.X - tpos.X, 0, root.Position.Z - tpos.Z) if away.Magnitude < 0.1 then away = Vector3.new(0, 0, 1) end local pos = Vector3.new(tpos.X, tpos.Y, tpos.Z) + away.Unit * SM.Config.KillStandOff root.CFrame = CFrame.lookAt(pos, Vector3.new(tpos.X, pos.Y, tpos.Z)) zeroVelocity(root) attack("TeleKill", e, "Kill") end)) end, Off = function() Scanner.Release("TeleKill") Combat.Locks.TeleKill = nil end, }) -- Aimbot: xoay Camera mượt về mục tiêu, có ngưỡng chống rung SM.Register("Aimbot", { On = function() Scanner.Acquire("Aimbot") local id = "CM_Aimbot" RunService:BindToRenderStep(id, Enum.RenderPriority.Camera.Value + 1, function(dt) local cam = Workspace.CurrentCamera local e = acquire("Aimbot") if not (cam and e) then return end local part = Combat.GetAimPart(e) if not part or not part.Parent then return end local cf = cam.CFrame local want = CFrame.lookAt(cf.Position, part.Position) local ang = math.acos(math.clamp(cf.LookVector:Dot(want.LookVector), -1, 1)) if ang < math.rad(0.15) then return end -- chống rung khi đã ngắm trúng cam.CFrame = cf:Lerp(want, 1 - math.exp(-SM.Config.AimSmooth * dt)) end) SM.GetMaid("Aimbot"):Add(function() RunService:UnbindFromRenderStep(id) end) end, Off = function() Scanner.Release("Aimbot") Combat.Locks.Aimbot = nil end, }) -- Aim Magic: chỉ gọi MagicHook khi người chơi bắn; KHÔNG chạm Camera SM.Register("AimMagic", { On = function() Scanner.Acquire("AimMagic") SM.GetMaid("AimMagic"):Add(UserInputService.InputBegan:Connect(function(input, processed) if processed then return end local t = input.UserInputType if t == Enum.UserInputType.MouseButton1 or t == Enum.UserInputType.Touch then local e = acquire("AimMagic") if e then pcall(Combat.MagicHook, e, Combat.GetAimPart(e).Position) end end end)) end, Off = function() Scanner.Release("AimMagic") Combat.Locks.AimMagic = nil end, }) -- Auto Bắn: tự gọi AttackHook vào mục tiêu; không đụng Camera/con trỏ SM.Register("AutoFire", { On = function() Scanner.Acquire("AutoFire") SM.GetMaid("AutoFire"):Add(RunService.Heartbeat:Connect(function() if not getCharParts() then return end local e = acquire("AutoFire") if e then attack("AutoFire", e, "Auto") end end)) end, Off = function() Scanner.Release("AutoFire") Combat.Locks.AutoFire = nil end, }) ---------------------------------------------------------------------- -- EspEngine ---------------------------------------------------------------------- local Esp = { Objs = {}, Gui = nil, Loop = nil } local KINDS = { "Line", "Box", "Name", "Distance" } local ESP_COLOR = Color3.fromRGB(255, 70, 70) local function ensureEspGui() if Esp.Gui and Esp.Gui.Parent then return Esp.Gui end local g = Instance.new("ScreenGui") g.Name = "CM_EspLayer" g.ResetOnSpawn = false g.IgnoreGuiInset = true g.DisplayOrder = 5 g.Parent = PlayerGui Esp.Gui = g return g end local function destroyKind(obj, kind) local el = obj[kind] if el then el:Destroy() obj[kind] = nil end end local function espAnyOn() return SM.IsOn("EspLine") or SM.IsOn("EspBox") or SM.IsOn("EspName") or SM.IsOn("EspDistance") end local function newLabel(size) local l = Instance.new("TextLabel") l.BackgroundTransparency = 1 l.Size = UDim2.fromOffset(220, 14) l.Font = Enum.Font.GothamBold l.TextSize = size l.TextColor3 = Color3.new(1, 1, 1) l.TextStrokeTransparency = 0.3 l.Active = false return l end local function espRender() local cam = Workspace.CurrentCamera local gui = ensureEspGui() local _, _, myRoot = getCharParts() local seen = {} if cam and myRoot then local vp = cam.ViewportSize for _, e in ipairs(Scanner.GetTargets()) do if Scanner.IsLive(e) then seen[e.Model] = true local obj = Esp.Objs[e.Model] if not obj then obj = {} Esp.Objs[e.Model] = obj end -- 3D -> 2D: chiếu 8 góc bounding box rồi lấy khung nhỏ nhất bao quanh local cf, size = e.Model:GetBoundingBox() local minX, minY, maxX, maxY = math.huge, math.huge, -math.huge, -math.huge local front = false local h = size / 2 for sx = -1, 1, 2 do for sy = -1, 1, 2 do for sz = -1, 1, 2 do local sp = cam:WorldToViewportPoint(cf:PointToWorldSpace(Vector3.new(h.X * sx, h.Y * sy, h.Z * sz))) if sp.Z > 0 then front = true minX = math.min(minX, sp.X) maxX = math.max(maxX, sp.X) minY = math.min(minY, sp.Y) maxY = math.max(maxY, sp.Y) end end end end local function ensure(kind, on, make) if not on then destroyKind(obj, kind) return nil end local el = obj[kind] if not el then el = make() el.Parent = gui obj[kind] = el end el.Visible = front return el end local cx = (minX + maxX) / 2 local dist = (e.Root.Position - myRoot.Position).Magnitude local box = ensure("Box", SM.IsOn("EspBox"), function() local f = Instance.new("Frame") f.BackgroundTransparency = 1 f.BorderSizePixel = 0 local s = Instance.new("UIStroke") s.Color = ESP_COLOR s.Thickness = 1.5 s.Parent = f return f end) if box and front then box.Position = UDim2.fromOffset(minX, minY) box.Size = UDim2.fromOffset(math.max(maxX - minX, 2), math.max(maxY - minY, 2)) end local line = ensure("Line", SM.IsOn("EspLine"), function() local f = Instance.new("Frame") f.BorderSizePixel = 0 f.BackgroundColor3 = ESP_COLOR f.AnchorPoint = Vector2.new(0.5, 0.5) return f end) if line and front then local p1, p2 = Vector2.new(vp.X / 2, 0), Vector2.new(cx, maxY) local d = p2 - p1 line.Size = UDim2.fromOffset(d.Magnitude, 1.5) line.Position = UDim2.fromOffset((p1.X + p2.X) / 2, (p1.Y + p2.Y) / 2) line.Rotation = math.deg(math.atan2(d.Y, d.X)) end local nm = ensure("Name", SM.IsOn("EspName"), function() return newLabel(13) end) if nm and front then nm.Text = e.Model.Name nm.AnchorPoint = Vector2.new(0.5, 1) nm.Position = UDim2.fromOffset(cx, minY - 2) end local ds = ensure("Distance", SM.IsOn("EspDistance"), function() return newLabel(12) end) if ds and front then ds.Text = string.format("%.0f studs (%.0f m)", dist, dist * 0.28) ds.AnchorPoint = Vector2.new(0.5, 0) ds.Position = UDim2.fromOffset(cx, maxY + 2) end end end end -- Mục tiêu rời tầm / chết / bị hủy => xóa sạch hình vẽ for model, obj in pairs(Esp.Objs) do if not seen[model] then for _, k in ipairs(KINDS) do destroyKind(obj, k) end Esp.Objs[model] = nil end end end local function espStopLoop() if Esp.Loop then Esp.Loop:Disconnect() Esp.Loop = nil end for model, obj in pairs(Esp.Objs) do for _, k in ipairs(KINDS) do destroyKind(obj, k) end Esp.Objs[model] = nil end if Esp.Gui then Esp.Gui:Destroy() Esp.Gui = nil end end local function registerEsp(feature, kind) SM.Register(feature, { On = function() Scanner.Acquire(feature) if not Esp.Loop then Esp.Loop = RunService.RenderStepped:Connect(espRender) end end, Off = function() for _, obj in pairs(Esp.Objs) do destroyKind(obj, kind) end Scanner.Release(feature) if not espAnyOn() then espStopLoop() end end, }) end registerEsp("EspLine", "Line") registerEsp("EspBox", "Box") registerEsp("EspName", "Name") registerEsp("EspDistance", "Distance") -- Esp Hologram: Highlight xuyên tường, tối đa 10 mục tiêu gần nhất (giới hạn Highlight của Roblox) SM.Register("EspHologram", { On = function() Scanner.Acquire("EspHologram") local maid = SM.GetMaid("EspHologram") local folder = maid:Add(Instance.new("Folder")) folder.Name = "CM_Hologram" folder.Parent = Workspace -- tạo từ client nên chỉ mình thấy local hl, acc = {}, 0 maid:Add(RunService.Heartbeat:Connect(function(dt) acc += dt if acc < 0.25 then return end acc = 0 local want, n = {}, 0 for _, e in ipairs(Scanner.GetTargets()) do if n >= 10 then break end if Scanner.IsLive(e) then n += 1 want[e.Model] = true if not hl[e.Model] then local h = Instance.new("Highlight") h.Adornee = e.Model h.FillColor = ESP_COLOR h.FillTransparency = 0.6 h.OutlineColor = Color3.new(1, 1, 1) h.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop h.Parent = folder hl[e.Model] = h end end end for m, h in pairs(hl) do if not want[m] then h:Destroy() hl[m] = nil end end end)) end, Off = function() Scanner.Release("EspHologram") end, -- Maid xóa Folder + toàn bộ Highlight }) -- Esp Workspace: quét workspace.Item (kiểm tra tồn tại), highlight 20 vật phẩm gần nhất SM.Register("EspWorkspace", { On = function() local maid = SM.GetMaid("EspWorkspace") local folder = maid:Add(Instance.new("Folder")) folder.Name = "CM_ItemHL" folder.Parent = Workspace local hl, acc = {}, 0.5 local function collect(parent, out, depth) for _, ch in ipairs(parent:GetChildren()) do if ch:IsA("Model") or ch:IsA("BasePart") then table.insert(out, ch) elseif ch:IsA("Folder") and depth < 2 then collect(ch, out, depth + 1) end end end local function posOf(inst) if inst:IsA("BasePart") then return inst.Position end local ok, cf = pcall(inst.GetPivot, inst) return ok and cf.Position or nil end local function clearAll() for k, h in pairs(hl) do h:Destroy() hl[k] = nil end end maid:Add(RunService.Heartbeat:Connect(function(dt) acc += dt if acc < 0.5 then return end acc = 0 local root = Workspace:FindFirstChild("Item") -- an toàn: có thể chưa tồn tại local _, _, myRoot = getCharParts() if not root or not myRoot then clearAll() return end local items = {} collect(root, items, 0) local scored = {} for _, it in ipairs(items) do local p = posOf(it) if p then table.insert(scored, { it, (p - myRoot.Position).Magnitude }) end end table.sort(scored, function(a, b) return a[2] < b[2] end) local want = {} for i = 1, math.min(20, #scored) do local it = scored[i][1] want[it] = true if not hl[it] then local h = Instance.new("Highlight") h.Adornee = it h.FillColor = Color3.fromRGB(255, 220, 60) h.FillTransparency = 0.6 h.OutlineColor = Color3.new(1, 1, 1) h.DepthMode = Enum.HighlightDepthMode.AlwaysOnTop h.Parent = folder hl[it] = h end end for it, h in pairs(hl) do if not want[it] or not it.Parent then h:Destroy() hl[it] = nil end end end)) end, Off = function() end, -- Maid xóa Folder + Highlight }) ---------------------------------------------------------------------- -- MovementAndWorld ---------------------------------------------------------------------- local Move = { Input = { Up = false, Down = false } } local fly = {} local function destroyFly() for _, k in ipairs({ "lv", "ao", "att" }) do if fly[k] then pcall(fly[k].Destroy, fly[k]) end end fly = {} end -- Tạo lại tự động nếu nhân vật hồi sinh (HRP mới) local function ensureFly(root) if fly.root ~= root or not fly.lv or not fly.lv.Parent then destroyFly() local att = Instance.new("Attachment") att.Name = "CM_FlyAtt" att.Parent = root local lv = Instance.new("LinearVelocity") lv.Attachment0 = att lv.RelativeTo = Enum.ActuatorRelativeTo.World lv.MaxForce = math.huge lv.VectorVelocity = Vector3.zero lv.Parent = root local ao = Instance.new("AlignOrientation") ao.Mode = Enum.OrientationAlignmentMode.OneAttachment ao.Attachment0 = att ao.MaxTorque = math.huge ao.Responsiveness = 40 ao.Enabled = false ao.Parent = root fly = { root = root, att = att, lv = lv, ao = ao } end return fly end function Move.AdjustDroneHeight(delta) SM.SetConfig("FlyDronHeight", SM.Config.FlyDronHeight + delta) end -- Fly Dron: giữ độ cao cố định (so với mặt đất), chỉ di chuyển ngang, úp mặt xuống. -- Nút +/- đổi độ cao, nhân vật lên/xuống từ từ. Mặc định 6. SM.Register("FlyDron", { Group = "Move", On = function() SM.GetMaid("FlyDron"):Add(RunService.Heartbeat:Connect(function() local c, h, root = getCharParts() if not root then return end local f = ensureFly(root) SM.Snapshot.Capture("FlyDron", h, "PlatformStand") h.PlatformStand = true local params = RaycastParams.new() params.FilterType = Enum.RaycastFilterType.Exclude params.FilterDescendantsInstances = { c } local res = Workspace:Raycast(root.Position, Vector3.new(0, -500, 0), params) local ground = res and res.Position.Y or (f.lastGround or root.Position.Y - SM.Config.FlyDronHeight) f.lastGround = ground local targetY = ground + SM.Config.FlyDronHeight local vy = math.clamp((targetY - root.Position.Y) * 6, -12, 12) -- lên/xuống từ từ local dir = h.MoveDirection local sp = SM.Config.FlySpeed f.lv.VectorVelocity = Vector3.new(dir.X * sp, vy, dir.Z * sp) -- úp mặt xuống, đầu hướng về phía di chuyển/camera local heading = Vector3.new(dir.X, 0, dir.Z) if heading.Magnitude < 0.1 then local cam = Workspace.CurrentCamera local lv = cam and cam.CFrame.LookVector or Vector3.zAxis heading = Vector3.new(lv.X, 0, lv.Z) end if heading.Magnitude < 0.01 then heading = Vector3.zAxis end f.ao.CFrame = CFrame.lookAt(Vector3.zero, Vector3.new(0, -1, 0), heading.Unit) f.ao.Enabled = true end)) end, Off = function() destroyFly() SM.Snapshot.Restore("FlyDron") end, }) -- Fly Air: bay tự do, giữ nguyên độ cao khi không bấm nút lên/xuống (không tự rơi) SM.Register("FlyAir", { Group = "Move", On = function() SM.GetMaid("FlyAir"):Add(RunService.Heartbeat:Connect(function() local _, h, root = getCharParts() if not root then return end local f = ensureFly(root) local sp = SM.Config.FlySpeed local dir = h.MoveDirection local vy = (Move.Input.Up and sp or 0) - (Move.Input.Down and sp or 0) f.lv.VectorVelocity = Vector3.new(dir.X * sp, vy, dir.Z * sp) end)) end, Off = function() destroyFly() Move.Input.Up, Move.Input.Down = false, false end, }) -- No Clip: tắt va chạm, khôi phục chính xác CanCollide ban đầu SM.Register("NoClip", { On = function() SM.GetMaid("NoClip"):Add(RunService.Stepped:Connect(function() local c = LP.Character if not c then return end for _, p in ipairs(c:GetDescendants()) do if p:IsA("BasePart") then SM.Snapshot.Capture("NoClip", p, "CanCollide") p.CanCollide = false end end end)) end, Off = function() SM.Snapshot.Restore("NoClip") end, }) -- Speed: WalkSpeed thời gian thực (đọc từ Config), khôi phục khi tắt SM.Register("Speed", { On = function() SM.GetMaid("Speed"):Add(RunService.Heartbeat:Connect(function() local _, h = getCharParts() if not h then return end SM.Snapshot.Capture("Speed", h, "WalkSpeed") h.WalkSpeed = SM.Config.WalkSpeed end)) end, Off = function() SM.Snapshot.Restore("Speed") end, }) -- Jumping Air: nhảy khi đang ở trên không SM.Register("JumpingAir", { On = function() local last = 0 SM.GetMaid("JumpingAir"):Add(UserInputService.JumpRequest:Connect(function() if os.clock() - last < 0.15 then return end local _, h = getCharParts() if h then last = os.clock() h:ChangeState(Enum.HumanoidStateType.Jumping) end end)) end, }) -- Night Vision: sáng + hết sương mù, lưu cấu hình gốc để trả lại SM.Register("NightVision", { On = function() local acc = 0.5 SM.GetMaid("NightVision"):Add(RunService.Heartbeat:Connect(function(dt) acc += dt if acc < 0.5 then return end -- áp lại định kỳ phòng game đổi lại ánh sáng acc = 0 local snap = SM.Snapshot.Capture for _, p in ipairs({ "Brightness", "ClockTime", "FogEnd", "FogStart", "GlobalShadows", "Ambient", "OutdoorAmbient", "ExposureCompensation" }) do snap("NightVision", Lighting, p) end Lighting.Brightness = 3 Lighting.ClockTime = 14 Lighting.FogStart = 1e8 Lighting.FogEnd = 1e9 Lighting.GlobalShadows = false Lighting.Ambient = Color3.fromRGB(190, 190, 190) Lighting.OutdoorAmbient = Color3.fromRGB(190, 190, 190) Lighting.ExposureCompensation = 0.3 for _, v in ipairs(Lighting:GetChildren()) do if v:IsA("Atmosphere") then snap("NightVision", v, "Density") snap("NightVision", v, "Haze") v.Density = 0 v.Haze = 0 end end end)) end, Off = function() SM.Snapshot.Restore("NightVision") end, }) -- Fix Lag: tắt (không xóa vĩnh viễn) hiệu ứng nặng, có thể khôi phục khi tắt local origQuality SM.Register("FixLag", { On = function() local maid = SM.GetMaid("FixLag") local token = { stop = false } maid:Add(function() token.stop = true end) pcall(function() origQuality = settings().Rendering.QualityLevel settings().Rendering.QualityLevel = Enum.QualityLevel.Level01 end) SM.Snapshot.Capture("FixLag", Lighting, "GlobalShadows") Lighting.GlobalShadows = false local function handle(inst) if inst:IsA("ParticleEmitter") or inst:IsA("Trail") or inst:IsA("Beam") or inst:IsA("Smoke") or inst:IsA("Fire") or inst:IsA("Sparkles") or inst:IsA("PostEffect") then SM.Snapshot.Capture("FixLag", inst, "Enabled") inst.Enabled = false elseif inst:IsA("BasePart") then SM.Snapshot.Capture("FixLag", inst, "CastShadow") inst.CastShadow = false end end maid:Add(Workspace.DescendantAdded:Connect(function(i) pcall(handle, i) end)) task.spawn(function() -- xử lý theo lô để không đứng hình local n = 0 local lists = { Lighting:GetDescendants(), Workspace:GetDescendants() } for _, list in ipairs(lists) do for _, d in ipairs(list) do if token.stop then return end pcall(handle, d) n += 1 if n % 250 == 0 then task.wait() end end end end) end, Off = function() SM.Snapshot.Restore("FixLag") if origQuality then pcall(function() settings().Rendering.QualityLevel = origQuality end) origQuality = nil end end, }) ---------------------------------------------------------------------- -- UIController ---------------------------------------------------------------------- local UI = { Maid = Maid.new() } local C = { bg = Color3.fromRGB(24, 24, 30), header = Color3.fromRGB(34, 34, 44), row = Color3.fromRGB(38, 38, 48), rowDrag = Color3.fromRGB(60, 60, 90), on = Color3.fromRGB(60, 190, 100), off = Color3.fromRGB(150, 60, 60), tab = Color3.fromRGB(44, 44, 56), tabOn = Color3.fromRGB(80, 110, 220), text = Color3.fromRGB(235, 235, 240), } local function make(class, props, parent) local i = Instance.new(class) for k, v in pairs(props) do i[k] = v end i.Parent = parent return i end local function corner(inst, r) make("UICorner", { CornerRadius = UDim.new(0, r or 6) }, inst) end local function isPointer(input) local t = input.UserInputType return t == Enum.UserInputType.MouseButton1 or t == Enum.UserInputType.Touch end local function isMove(input) local t = input.UserInputType return t == Enum.UserInputType.MouseMovement or t == Enum.UserInputType.Touch end local function fmt(v) return tostring(math.floor(v * 100 + 0.5) / 100) end local function makeDraggable(handle, target) local dragging, startPos, startInput handle.InputBegan:Connect(function(input) if isPointer(input) then dragging, startInput, startPos = true, input.Position, target.Position local conn conn = input.Changed:Connect(function() if input.UserInputState == Enum.UserInputState.End then dragging = false conn:Disconnect() end end) end end) UI.Maid:Add(UserInputService.InputChanged:Connect(function(input) if dragging and isMove(input) then local d = input.Position - startInput target.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + d.X, startPos.Y.Scale, startPos.Y.Offset + d.Y) end end)) end local function reorder(page, row, pointerY) local others = {} for _, c in ipairs(page:GetChildren()) do if c:IsA("Frame") and c ~= row and c:GetAttribute("Row") then table.insert(others, c) end end table.sort(others, function(a, b) return a.LayoutOrder < b.LayoutOrder end) local idx = 1 for _, o in ipairs(others) do if pointerY > o.AbsolutePosition.Y + o.AbsoluteSize.Y / 2 then idx += 1 end end table.insert(others, idx, row) for i, o in ipairs(others) do o.LayoutOrder = i end end function UI.Build() local gui = UI.Maid:Add(make("ScreenGui", { Name = "CM_Menu", ResetOnSpawn = false, IgnoreGuiInset = true, DisplayOrder = 100, ZIndexBehavior = Enum.ZIndexBehavior.Sibling, }, PlayerGui)) local main = make("Frame", { Name = "Main", Size = UDim2.fromOffset(300, 380), Position = UDim2.fromOffset(16, 80), BackgroundColor3 = C.bg, BorderSizePixel = 0, Active = true, ClipsDescendants = true, }, gui) corner(main, 8) local header = make("Frame", { Size = UDim2.new(1, 0, 0, 34), BackgroundColor3 = C.header, BorderSizePixel = 0 }, main) make("TextLabel", { Size = UDim2.new(1, -50, 1, 0), Position = UDim2.fromOffset(10, 0), BackgroundTransparency = 1, Text = "Menu điều khiển", Font = Enum.Font.GothamBold, TextSize = 14, TextColor3 = C.text, TextXAlignment = Enum.TextXAlignment.Left, }, header) local collapseBtn = make("TextButton", { Size = UDim2.fromOffset(30, 24), Position = UDim2.new(1, -36, 0, 5), Text = "–", Font = Enum.Font.GothamBold, TextSize = 18, TextColor3 = C.text, BackgroundColor3 = C.tab, BorderSizePixel = 0, }, header) corner(collapseBtn, 6) makeDraggable(header, main) local tabBar = make("Frame", { Size = UDim2.new(1, -12, 0, 28), Position = UDim2.fromOffset(6, 38), BackgroundTransparency = 1, }, main) make("UIListLayout", { FillDirection = Enum.FillDirection.Horizontal, Padding = UDim.new(0, 6), SortOrder = Enum.SortOrder.LayoutOrder, }, tabBar) local body = make("Frame", { Size = UDim2.new(1, -12, 1, -74), Position = UDim2.fromOffset(6, 70), BackgroundTransparency = 1, }, main) -- Thu gọn / mở rộng local collapsed = false local function setCollapsed(v) collapsed = v if v then body.Visible, tabBar.Visible = false, false TweenService:Create(main, TweenInfo.new(0.18), { Size = UDim2.fromOffset(300, 34) }):Play() collapseBtn.Text = "+" else TweenService:Create(main, TweenInfo.new(0.18), { Size = UDim2.fromOffset(300, 380) }):Play() collapseBtn.Text = "–" task.delay(0.18, function() if not collapsed and main.Parent then body.Visible, tabBar.Visible = true, true end end) end end collapseBtn.Activated:Connect(function() setCollapsed(not collapsed) end) -- Trang & tab local pages, tabBtns = {}, {} local function showTab(name) for n, p in pairs(pages) do p.Visible = (n == name) end for n, b in pairs(tabBtns) do TweenService:Create(b, TweenInfo.new(0.15), { BackgroundColor3 = n == name and C.tabOn or C.tab }):Play() end end local order = { "Main", "Esp", "Khác" } for i, name in ipairs(order) do local b = make("TextButton", { Size = UDim2.new(1 / 3, -4, 1, 0), LayoutOrder = i, Text = name, Font = Enum.Font.GothamBold, TextSize = 13, TextColor3 = C.text, BackgroundColor3 = C.tab, BorderSizePixel = 0, }, tabBar) corner(b, 6) b.Activated:Connect(function() showTab(name) end) tabBtns[name] = b local page = make("ScrollingFrame", { Size = UDim2.fromScale(1, 1), BackgroundTransparency = 1, BorderSizePixel = 0, ScrollBarThickness = 3, CanvasSize = UDim2.new(), AutomaticCanvasSize = Enum.AutomaticSize.Y, Visible = false, }, body) make("UIListLayout", { Padding = UDim.new(0, 5), SortOrder = Enum.SortOrder.LayoutOrder }, page) pages[name] = page end -- Kéo sắp xếp lại chức năng local draggingRow UI.Maid:Add(UserInputService.InputChanged:Connect(function(input) if draggingRow and isMove(input) then reorder(draggingRow.Parent, draggingRow, input.Position.Y) end end)) UI.Maid:Add(UserInputService.InputEnded:Connect(function(input) if draggingRow and isPointer(input) then draggingRow.BackgroundColor3 = C.row draggingRow.Parent.ScrollingEnabled = true draggingRow = nil end end)) local counters = {} local function newRow(page, label) counters[page] = (counters[page] or 0) + 1 local row = make("Frame", { Size = UDim2.new(1, -8, 0, 34), BackgroundColor3 = C.row, BorderSizePixel = 0, LayoutOrder = counters[page], }, page) row:SetAttribute("Row", true) corner(row, 6) local handle = make("TextButton", { Size = UDim2.fromOffset(24, 34), BackgroundTransparency = 1, Text = "≡", Font = Enum.Font.GothamBold, TextSize = 16, TextColor3 = Color3.fromRGB(150, 150, 170), }, row) handle.InputBegan:Connect(function(input) if isPointer(input) then draggingRow = row row.BackgroundColor3 = C.rowDrag page.ScrollingEnabled = false end end) make("TextLabel", { Size = UDim2.new(1, -150, 1, 0), Position = UDim2.fromOffset(26, 0), BackgroundTransparency = 1, Text = label, Font = Enum.Font.Gotham, TextSize = 12, TextColor3 = C.text, TextXAlignment = Enum.TextXAlignment.Left, TextTruncate = Enum.TextTruncate.AtEnd, }, row) return row end local function addToggle(pageName, label, feature) local row = newRow(pages[pageName], label) local btn = make("TextButton", { Size = UDim2.fromOffset(54, 24), Position = UDim2.new(1, -60, 0.5, -12), Font = Enum.Font.GothamBold, TextSize = 12, TextColor3 = Color3.new(1, 1, 1), BorderSizePixel = 0, }, row) corner(btn, 6) local function refresh(on) btn.Text = on and "ON" or "OFF" TweenService:Create(btn, TweenInfo.new(0.12), { BackgroundColor3 = on and C.on or C.off }):Play() end btn.Activated:Connect(function() SM.Toggle(feature) end) UI.Maid:Add(SM.Changed.Event:Connect(function(name, on) if name == feature then refresh(on) end end)) refresh(SM.IsOn(feature)) end local function addNumber(pageName, label, key, step) local row = newRow(pages[pageName], label) local function small(text, x) local b = make("TextButton", { Size = UDim2.fromOffset(22, 24), Position = UDim2.new(1, x, 0.5, -12), Text = text, Font = Enum.Font.GothamBold, TextSize = 14, TextColor3 = C.text, BackgroundColor3 = C.tab, BorderSizePixel = 0, }, row) corner(b, 6) return b end local minus, plus = small("-", -102), small("+", -28) local box = make("TextBox", { Size = UDim2.fromOffset(48, 24), Position = UDim2.new(1, -78, 0.5, -12), Text = fmt(SM.Config[key]), Font = Enum.Font.GothamBold, TextSize = 12, TextColor3 = C.text, BackgroundColor3 = C.bg, BorderSizePixel = 0, ClearTextOnFocus = false, }, row) corner(box, 6) box.FocusLost:Connect(function() local v = tonumber(box.Text) -- chỉ nhận số hợp lệ if v then SM.SetConfig(key, v) end box.Text = fmt(SM.Config[key]) end) minus.Activated:Connect(function() SM.SetConfig(key, SM.Config[key] - step) end) plus.Activated:Connect(function() SM.SetConfig(key, SM.Config[key] + step) end) UI.Maid:Add(SM.ConfigChanged.Event:Connect(function(k, v) if k == key then box.Text = fmt(v) end end)) end local function addButton(pageName, label, text, fn) local row = newRow(pages[pageName], label) local b = make("TextButton", { Size = UDim2.fromOffset(70, 24), Position = UDim2.new(1, -76, 0.5, -12), Text = text, Font = Enum.Font.GothamBold, TextSize = 12, TextColor3 = Color3.new(1, 1, 1), BackgroundColor3 = C.off, BorderSizePixel = 0, }, row) corner(b, 6) b.Activated:Connect(fn) end -- Tab Main addToggle("Main", "Tele Dron", "TeleDron") addNumber("Main", "Độ cao Tele Dron", "DroneHeightOffset", 1) addToggle("Main", "Tele Kill", "TeleKill") addToggle("Main", "Aimbot", "Aimbot") addToggle("Main", "Aim Magic", "AimMagic") addToggle("Main", "Auto Bắn", "AutoFire") addNumber("Main", "Phạm vi (studs)", "ScanRange", 10) -- Tab Esp addToggle("Esp", "Esp Line", "EspLine") addToggle("Esp", "Esp Box", "EspBox") addToggle("Esp", "Esp Name", "EspName") addToggle("Esp", "Esp Distance", "EspDistance") addToggle("Esp", "Esp Hologram", "EspHologram") addToggle("Esp", "Esp Workspace", "EspWorkspace") -- Tab Khác addToggle("Khác", "Fly Dron", "FlyDron") addNumber("Khác", "Độ cao Fly Dron", "FlyDronHeight", 1) addToggle("Khác", "No Clip", "NoClip") addToggle("Khác", "Fly Air", "FlyAir") addNumber("Khác", "Fly Speed", "FlySpeed", 5) addToggle("Khác", "Speed", "Speed") addNumber("Khác", "Tốc độ chạy", "WalkSpeed", 5) addToggle("Khác", "Jumping Air", "JumpingAir") addToggle("Khác", "Night Vision", "NightVision") addToggle("Khác", "Fix Lag", "FixLag") addButton("Khác", "Gỡ menu (tắt tất cả)", "Unload", function() if _G.__CM_Unload then _G.__CM_Unload() end end) -- Cụm nút bay: lên/xuống (Fly Air: giữ để bay; Fly Dron: giữ để tăng/giảm độ cao dần) local cluster = make("Frame", { Size = UDim2.fromOffset(58, 150), Position = UDim2.new(1, -76, 0.5, -75), BackgroundColor3 = C.bg, BorderSizePixel = 0, Visible = false, }, gui) corner(cluster, 8) local info = make("TextLabel", { Size = UDim2.new(1, 0, 0, 26), Position = UDim2.fromOffset(0, 62), BackgroundTransparency = 1, Text = "", Font = Enum.Font.GothamBold, TextSize = 12, TextColor3 = C.text, }, cluster) local function arrow(text, y) local b = make("TextButton", { Size = UDim2.new(1, -10, 0, 52), Position = UDim2.fromOffset(5, y), Text = text, Font = Enum.Font.GothamBold, TextSize = 22, TextColor3 = C.text, BackgroundColor3 = C.tab, BorderSizePixel = 0, }, cluster) corner(b, 8) return b end local upBtn, downBtn = arrow("▲", 5), arrow("▼", 93) local holdToken local function bindHold(btn, dir) btn.InputBegan:Connect(function(input) if not isPointer(input) then return end local token = {} holdToken = token if SM.IsOn("FlyAir") then Move.Input[dir > 0 and "Up" or "Down"] = true end if SM.IsOn("FlyDron") then task.spawn(function() while holdToken == token do Move.AdjustDroneHeight(dir * 0.5) task.wait(0.1) end end) end local conn conn = input.Changed:Connect(function() if input.UserInputState == Enum.UserInputState.End then conn:Disconnect() if holdToken == token then holdToken = nil end Move.Input.Up, Move.Input.Down = false, false end end) end) end bindHold(upBtn, 1) bindHold(downBtn, -1) UI.Maid:Add(function() holdToken = nil end) local function refreshCluster() cluster.Visible = SM.IsOn("FlyAir") or SM.IsOn("FlyDron") info.Text = SM.IsOn("FlyDron") and ("H: " .. fmt(SM.Config.FlyDronHeight)) or "" end UI.Maid:Add(SM.Changed.Event:Connect(refreshCluster)) UI.Maid:Add(SM.ConfigChanged.Event:Connect(refreshCluster)) showTab("Main") end ---------------------------------------------------------------------- -- Khởi chạy & gỡ sạch ---------------------------------------------------------------------- local function Unload() for name in pairs(SM.Handlers) do SM.Set(name, false) end -- tắt hết => khôi phục Snapshot, ngắt kết nối for _, m in pairs(SM.Maids) do m:Clean() end Scanner.Stop() espStopLoop() UI.Maid:Clean() SM.Changed:Destroy() SM.ConfigChanged:Destroy() _G.__CM_Unload = nil end _G.__CM_Unload = Unload UI.Build()