Created
July 25, 2026 04:21
-
-
Save DuyNgao2306/f17682756934b623bf3a353bcab66f27 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- [[ SMART MACRO - THE ULTIMATE FIX (AIM & UI 100%) ]] -- | |
| local Players = game:GetService("Players") | |
| local UserInputService = game:GetService("UserInputService") | |
| local VirtualInputManager = game:GetService("VirtualInputManager") | |
| local GuiService = game:GetService("GuiService") | |
| local LocalPlayer = Players.LocalPlayer | |
| local PlayerGui = LocalPlayer:WaitForChild("PlayerGui") | |
| math.randomseed(os.time()) | |
| if PlayerGui:FindFirstChild("MacroSystemGui") then | |
| PlayerGui.MacroSystemGui:Destroy() | |
| end | |
| local recordedClicks = {} | |
| local MAX_CLICKS = 200 | |
| local isSelecting = false | |
| local isRunning = false | |
| local lastClickTime = 0 | |
| local connections = {} | |
| -- 1. TẠO GIAO DIỆN UI | |
| local ScreenGui = Instance.new("ScreenGui") | |
| ScreenGui.Name = "MacroSystemGui" | |
| ScreenGui.ResetOnSpawn = false | |
| ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling | |
| ScreenGui.DisplayOrder = 999 | |
| ScreenGui.Parent = PlayerGui | |
| local MainFrame = Instance.new("Frame") | |
| MainFrame.Name = "MainFrame" | |
| MainFrame.Size = UDim2.new(0, 300, 0, 250) | |
| MainFrame.Position = UDim2.new(0.5, -150, 0.3, 0) | |
| MainFrame.BackgroundColor3 = Color3.fromRGB(25, 27, 38) | |
| MainFrame.BorderSizePixel = 0 | |
| MainFrame.Active = true | |
| MainFrame.Parent = ScreenGui | |
| local UICorner = Instance.new("UICorner") | |
| UICorner.CornerRadius = UDim.new(0, 10) | |
| UICorner.Parent = MainFrame | |
| local UIStroke = Instance.new("UIStroke") | |
| UIStroke.Color = Color3.fromRGB(60, 65, 85) | |
| UIStroke.Thickness = 1.5 | |
| UIStroke.Parent = MainFrame | |
| local Header = Instance.new("Frame") | |
| Header.Size = UDim2.new(1, 0, 0, 38) | |
| Header.BackgroundColor3 = Color3.fromRGB(35, 38, 52) | |
| Header.BorderSizePixel = 0 | |
| Header.Parent = MainFrame | |
| local HeaderCorner = Instance.new("UICorner") | |
| HeaderCorner.CornerRadius = UDim.new(0, 10) | |
| HeaderCorner.Parent = Header | |
| local Title = Instance.new("TextLabel") | |
| Title.Size = UDim2.new(1, -50, 1, 0) | |
| Title.Position = UDim2.new(0, 12, 0, 0) | |
| Title.BackgroundTransparency = 1 | |
| Title.Text = "🎯 SMART MACRO (ULTIMATE)" | |
| Title.TextColor3 = Color3.fromRGB(255, 255, 255) | |
| Title.TextSize = 13 | |
| Title.Font = Enum.Font.GothamBold | |
| Title.TextXAlignment = Enum.TextXAlignment.Left | |
| Title.Parent = Header | |
| local CloseBtn = Instance.new("TextButton") | |
| CloseBtn.Size = UDim2.new(0, 30, 0, 30) | |
| CloseBtn.Position = UDim2.new(1, -5, 0.5, 0) | |
| CloseBtn.AnchorPoint = Vector2.new(1, 0.5) | |
| CloseBtn.BackgroundTransparency = 1 | |
| CloseBtn.Text = "✕" | |
| CloseBtn.TextColor3 = Color3.fromRGB(255, 71, 87) | |
| CloseBtn.TextSize = 18 | |
| CloseBtn.Font = Enum.Font.GothamBold | |
| CloseBtn.ZIndex = 10 | |
| CloseBtn.Parent = Header | |
| local StatusLabel = Instance.new("TextLabel") | |
| StatusLabel.Size = UDim2.new(1, -24, 0, 20) | |
| StatusLabel.Position = UDim2.new(0, 12, 0, 48) | |
| StatusLabel.BackgroundTransparency = 1 | |
| StatusLabel.Text = "Trạng thái: Đang nghỉ" | |
| StatusLabel.TextColor3 = Color3.fromRGB(180, 185, 200) | |
| StatusLabel.TextSize = 12 | |
| StatusLabel.Font = Enum.Font.GothamMedium | |
| StatusLabel.TextXAlignment = Enum.TextXAlignment.Left | |
| StatusLabel.Parent = MainFrame | |
| local CountLabel = Instance.new("TextLabel") | |
| CountLabel.Size = UDim2.new(1, -24, 0, 20) | |
| CountLabel.Position = UDim2.new(0, 12, 0, 68) | |
| CountLabel.BackgroundTransparency = 1 | |
| CountLabel.Text = "Đã lưu: 0 / " .. MAX_CLICKS | |
| CountLabel.TextColor3 = Color3.fromRGB(130, 135, 150) | |
| CountLabel.TextSize = 11 | |
| CountLabel.Font = Enum.Font.Gotham | |
| CountLabel.TextXAlignment = Enum.TextXAlignment.Left | |
| CountLabel.Parent = MainFrame | |
| local TimerLabel = Instance.new("TextLabel") | |
| TimerLabel.Size = UDim2.new(1, -24, 0, 20) | |
| TimerLabel.Position = UDim2.new(0, 12, 0, 88) | |
| TimerLabel.BackgroundTransparency = 1 | |
| TimerLabel.Text = "⏱️ Thời gian chạy: 00:00:00" | |
| TimerLabel.TextColor3 = Color3.fromRGB(85, 239, 196) | |
| TimerLabel.TextSize = 12 | |
| TimerLabel.Font = Enum.Font.GothamBold | |
| TimerLabel.TextXAlignment = Enum.TextXAlignment.Left | |
| TimerLabel.Parent = MainFrame | |
| local function createButton(name, text, pos, size, color) | |
| local btn = Instance.new("TextButton") | |
| btn.Name = name | |
| btn.Size = size | |
| btn.Position = pos | |
| btn.BackgroundColor3 = color | |
| btn.Text = text | |
| btn.TextColor3 = Color3.fromRGB(255, 255, 255) | |
| btn.Font = Enum.Font.GothamBold | |
| btn.TextSize = 13 | |
| btn.ZIndex = 10 | |
| btn.Parent = MainFrame | |
| local corner = Instance.new("UICorner") | |
| corner.CornerRadius = UDim.new(0, 8) | |
| corner.Parent = btn | |
| return btn | |
| end | |
| local SelectBtn = createButton("SelectBtn", "Bắt đầu chọn", UDim2.new(0, 12, 0, 118), UDim2.new(1, -24, 0, 34), Color3.fromRGB(108, 92, 231)) | |
| local StartBtn = createButton("StartBtn", "Chạy Macro", UDim2.new(0, 12, 0, 160), UDim2.new(0, 175, 0, 34), Color3.fromRGB(0, 184, 148)) | |
| local ClearBtn = createButton("ClearBtn", "Xóa", UDim2.new(0, 195, 0, 160), UDim2.new(0, 93, 0, 34), Color3.fromRGB(225, 112, 85)) | |
| local function bindClick(button, callback) | |
| table.insert(connections, button.Activated:Connect(callback)) | |
| end | |
| -- 2. KÉO THẢ UI | |
| local dragging, dragStart, startPos | |
| table.insert(connections, Header.InputBegan:Connect(function(input) | |
| if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then | |
| dragging = true | |
| dragStart = input.Position | |
| startPos = MainFrame.Position | |
| end | |
| end)) | |
| table.insert(connections, UserInputService.InputChanged:Connect(function(input) | |
| if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then | |
| local delta = input.Position - dragStart | |
| MainFrame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y) | |
| end | |
| end)) | |
| table.insert(connections, UserInputService.InputEnded:Connect(function(input) | |
| if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then | |
| dragging = false | |
| end | |
| end)) | |
| local function isClickingOnMacroUI(clickPos) | |
| local framePos = MainFrame.AbsolutePosition | |
| local frameSize = MainFrame.AbsoluteSize | |
| return clickPos.X >= framePos.X and clickPos.X <= (framePos.X + frameSize.X) and | |
| clickPos.Y >= framePos.Y and clickPos.Y <= (framePos.Y + frameSize.Y) | |
| end | |
| -- 3. LOGIC GHI NHẬN TỌA ĐỘ KÉP (CỰC CHUẨN) | |
| local function stopRunning() | |
| isRunning = false | |
| StartBtn.Text = "Chạy Macro" | |
| StartBtn.BackgroundColor3 = Color3.fromRGB(0, 184, 148) | |
| StatusLabel.Text = "Trạng thái: Đã dừng" | |
| StatusLabel.TextColor3 = Color3.fromRGB(180, 185, 200) | |
| end | |
| local function stopSelecting() | |
| isSelecting = false | |
| SelectBtn.Text = "Bắt đầu chọn" | |
| SelectBtn.BackgroundColor3 = Color3.fromRGB(108, 92, 231) | |
| StatusLabel.Text = "Trạng thái: Hoàn tất chọn" | |
| StatusLabel.TextColor3 = Color3.fromRGB(180, 185, 200) | |
| end | |
| table.insert(connections, UserInputService.InputBegan:Connect(function(input) | |
| if not isSelecting then return end | |
| if isClickingOnMacroUI(input.Position) then return end | |
| if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then | |
| if #recordedClicks >= MAX_CLICKS then | |
| StatusLabel.Text = "Lỗi: Đạt giới hạn!" | |
| return | |
| end | |
| local now = os.clock() | |
| local delayTime = (#recordedClicks > 0) and math.max(now - lastClickTime, 0.05) or 0.1 | |
| lastClickTime = now | |
| -- Tọa độ THÔ (Dùng quét UI nội bộ) | |
| local rawX = input.Position.X | |
| local rawY = input.Position.Y | |
| -- Tọa độ TUYỆT ĐỐI (Dùng cho VirtualInputManager giả lập) | |
| local realX, realY | |
| if input.UserInputType == Enum.UserInputType.Touch then | |
| local inset = GuiService:GetGuiInset() | |
| realX = rawX | |
| realY = rawY + inset.Y -- Bù Topbar cho Mobile | |
| else | |
| local mouseLoc = UserInputService:GetMouseLocation() | |
| realX = mouseLoc.X | |
| realY = mouseLoc.Y -- Lấy chuẩn 100% cho PC | |
| end | |
| table.insert(recordedClicks, { | |
| x = realX, | |
| y = realY, | |
| rawX = rawX, | |
| rawY = rawY, | |
| inputType = input.UserInputType, | |
| delay = delayTime | |
| }) | |
| CountLabel.Text = "Đã lưu: " .. #recordedClicks .. " / " .. MAX_CLICKS | |
| StatusLabel.Text = "Lưu chuẩn: X:" .. math.floor(realX) .. " Y:" .. math.floor(realY) | |
| StatusLabel.TextColor3 = Color3.fromRGB(253, 203, 110) | |
| end | |
| end)) | |
| -- SỰ KIỆN NÚT BẤM | |
| bindClick(SelectBtn, function() | |
| if isRunning then stopRunning() end | |
| isSelecting = not isSelecting | |
| if isSelecting then | |
| SelectBtn.Text = "Dừng chọn" | |
| SelectBtn.BackgroundColor3 = Color3.fromRGB(225, 112, 85) | |
| StatusLabel.Text = "Trạng thái: Đang thu thập tọa độ..." | |
| StatusLabel.TextColor3 = Color3.fromRGB(253, 203, 110) | |
| lastClickTime = os.clock() | |
| else | |
| stopSelecting() | |
| end | |
| end) | |
| bindClick(StartBtn, function() | |
| if isSelecting then stopSelecting() end | |
| if isRunning then stopRunning(); return end | |
| if #recordedClicks == 0 then return end | |
| isRunning = true | |
| StartBtn.Text = "Dừng Macro" | |
| StartBtn.BackgroundColor3 = Color3.fromRGB(214, 48, 49) | |
| StatusLabel.Text = "Trạng thái: Đang chạy (Fix Aim)..." | |
| local startTime = os.time() | |
| task.spawn(function() | |
| while isRunning do | |
| local elapsed = os.time() - startTime | |
| local h = math.floor(elapsed / 3600) | |
| local m = math.floor((elapsed % 3600) / 60) | |
| local s = elapsed % 60 | |
| TimerLabel.Text = string.format("⏱️ Thời gian chạy: %02d:%02d:%02d", h, m, s) | |
| task.wait(1) | |
| end | |
| end) | |
| task.spawn(function() | |
| while isRunning do | |
| for _, data in ipairs(recordedClicks) do | |
| if not isRunning then break end | |
| local randomJitter = math.random(-15, 30) / 1000 | |
| task.wait(math.max(data.delay + randomJitter, 0.05)) | |
| if not isRunning then break end | |
| -- 1. CLICK XUYÊN BẢN ĐỒ VỚI TỌA ĐỘ TUYỆT ĐỐI (SỬA LỖI XỊT CLICK) | |
| pcall(function() | |
| if data.inputType == Enum.UserInputType.Touch then | |
| VirtualInputManager:SendTouchEvent(0, data.x, data.y, true) | |
| task.wait(0.04) | |
| VirtualInputManager:SendTouchEvent(0, data.x, data.y, false) | |
| else | |
| VirtualInputManager:SendMouseButtonEvent(data.x, data.y, 0, true, game, 1) | |
| task.wait(0.04) | |
| VirtualInputManager:SendMouseButtonEvent(data.x, data.y, 0, false, game, 1) | |
| end | |
| end) | |
| -- 2. ÉP CLICK GIAO DIỆN UI (SỬA LỖI KHÔNG BẤM ĐƯỢC BUTTON/FRAME) | |
| pcall(function() | |
| local guiObjects = PlayerGui:GetGuiObjectsAtPosition(data.rawX, data.rawY) | |
| for _, gui in ipairs(guiObjects) do | |
| -- Quét các loại GUI có thể tương tác | |
| if gui:IsA("GuiButton") or gui:IsA("TextButton") or gui:IsA("ImageButton") then | |
| if getconnections then | |
| for _, conn in ipairs(getconnections(gui.Activated)) do conn:Fire() end | |
| for _, conn in ipairs(getconnections(gui.MouseButton1Click)) do conn:Fire() end | |
| for _, conn in ipairs(getconnections(gui.MouseButton1Down)) do conn:Fire() end | |
| for _, conn in ipairs(getconnections(gui.MouseButton1Up)) do conn:Fire() end | |
| end | |
| break | |
| end | |
| end | |
| end) | |
| -- 3. Kích hoạt Tool (Kiếm/Súng/Skill) | |
| local char = LocalPlayer.Character | |
| if char then | |
| local tool = char:FindFirstChildOfClass("Tool") | |
| if tool then tool:Activate() end | |
| end | |
| end | |
| task.wait(math.random(5, 10) / 100) | |
| end | |
| end) | |
| end) | |
| bindClick(ClearBtn, function() | |
| if isRunning then stopRunning() end | |
| if isSelecting then stopSelecting() end | |
| table.clear(recordedClicks) | |
| CountLabel.Text = "Đã lưu: 0 / " .. MAX_CLICKS | |
| TimerLabel.Text = "⏱️ Thời gian chạy: 00:00:00" | |
| StatusLabel.Text = "Trạng thái: Đã xóa toàn bộ" | |
| end) | |
| bindClick(CloseBtn, function() | |
| isRunning = false | |
| isSelecting = false | |
| for _, conn in ipairs(connections) do | |
| if conn.Connected then conn:Disconnect() end | |
| end | |
| table.clear(connections) | |
| ScreenGui:Destroy() | |
| end) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment