PC55654

Universal Aimbot/ESP

Nov 10th, 2025
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 17.19 KB | None | 0 0
  1. -- Full Aimbot + ESP LocalScript
  2. -- Combines your original aimbot GUI + fixed toggle behavior + ESP + Team ESP + Aim part selector (Head/Torso/Random)
  3.  
  4. local Players = game:GetService("Players")
  5. local RunService = game:GetService("RunService")
  6. local UserInputService = game:GetService("UserInputService")
  7.  
  8. local player = Players.LocalPlayer
  9. local camera = workspace.CurrentCamera
  10. local mouse = player:GetMouse()
  11.  
  12. -- Default Settings
  13. local aimbotEnabled = false
  14. local aimPartOption = "Head"      -- "Head", "Torso", "Random"
  15. local circleRadius = 150
  16. local smoothness = 0.15
  17. local aimbotMode = "Hold"        -- "Hold" or "Toggle"
  18. local activationKey = Enum.UserInputType.MouseButton2 -- default Right Click
  19.  
  20. -- ESP Settings
  21. local espEnabled = false
  22. local teamEspEnabled = false
  23. local defaultESPColor = Color3.fromRGB(255,255,255)
  24.  
  25. -- Runtime Vars
  26. local holdingKey = false
  27. local target = nil               -- current target part
  28. local toggleActive = false       -- Toggle-mode aiming on/off
  29. local playerESPs = {}           -- map player -> {BillboardGui, Frame, TextLabel}
  30. local aimCandidates = {"Head", "Torso"} -- used for Random
  31.  
  32. --// Create Circle (same as before)
  33. local circle = Drawing.new("Circle")
  34. circle.Thickness = 1.5
  35. circle.NumSides = 64
  36. circle.Radius = circleRadius
  37. circle.Color = Color3.fromRGB(0, 255, 255)
  38. circle.Filled = false
  39. circle.Visible = true
  40. circle.Transparency = 0.8
  41.  
  42. --// Create UI
  43. local ScreenGui = Instance.new("ScreenGui", game.CoreGui)
  44. ScreenGui.Name = "AimbotSettingsUI"
  45.  
  46. local Frame = Instance.new("Frame", ScreenGui)
  47. Frame.Size = UDim2.new(0, 340, 0, 300)
  48. Frame.Position = UDim2.new(0.5, -170, 0.5, -150)
  49. Frame.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
  50. Frame.Active = true
  51. Frame.Draggable = true
  52. Frame.Visible = true
  53. Frame.BorderSizePixel = 0
  54.  
  55. local Title = Instance.new("TextLabel", Frame)
  56. Title.Text = "Aimbot Settings"
  57. Title.Size = UDim2.new(1, 0, 0, 30)
  58. Title.BackgroundColor3 = Color3.fromRGB(0, 170, 255)
  59. Title.TextColor3 = Color3.fromRGB(255, 255, 255)
  60. Title.Font = Enum.Font.SourceSansBold
  61. Title.TextSize = 20
  62.  
  63. -- Aimbot toggle button
  64. local toggleButton = Instance.new("TextButton", Frame)
  65. toggleButton.Size = UDim2.new(0.45, 0, 0, 30)
  66. toggleButton.Position = UDim2.new(0.05, 0, 0.2, 0)
  67. toggleButton.Text = "Aimbot: OFF"
  68. toggleButton.BackgroundColor3 = Color3.fromRGB(255, 60, 60)
  69. toggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  70.  
  71. toggleButton.MouseButton1Click:Connect(function()
  72.     aimbotEnabled = not aimbotEnabled
  73.     if aimbotEnabled then
  74.         toggleButton.Text = "Aimbot: ON"
  75.         toggleButton.BackgroundColor3 = Color3.fromRGB(0, 200, 100)
  76.     else
  77.         toggleButton.Text = "Aimbot: OFF"
  78.         toggleButton.BackgroundColor3 = Color3.fromRGB(255, 60, 60)
  79.         toggleActive = false
  80.         target = nil
  81.     end
  82. end)
  83.  
  84. -- Mode selector (Hold/Toggle)
  85. local modeButton = Instance.new("TextButton", Frame)
  86. modeButton.Size = UDim2.new(0.45, 0, 0, 30)
  87. modeButton.Position = UDim2.new(0.52, 0, 0.2, 0)
  88. modeButton.Text = "Mode: Hold"
  89. modeButton.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
  90. modeButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  91.  
  92. modeButton.MouseButton1Click:Connect(function()
  93.     aimbotMode = (aimbotMode == "Hold" and "Toggle" or "Hold")
  94.     modeButton.Text = "Mode: " .. aimbotMode
  95.     -- Reset toggle state when switching mode
  96.     toggleActive = false
  97.     target = nil
  98. end)
  99.  
  100. -- Activation key button
  101. local keyButton = Instance.new("TextButton", Frame)
  102. keyButton.Size = UDim2.new(0.9, 0, 0, 30)
  103. keyButton.Position = UDim2.new(0.05, 0, 0.35, 0)
  104. keyButton.Text = "Activation Key: Right Click"
  105. keyButton.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
  106. keyButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  107.  
  108. local waitingForKey = false
  109. keyButton.MouseButton1Click:Connect(function()
  110.     waitingForKey = true
  111.     keyButton.Text = "Press any key..."
  112. end)
  113.  
  114. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  115.     if waitingForKey and not gameProcessed then
  116.         waitingForKey = false
  117.         if input.UserInputType == Enum.UserInputType.Keyboard then
  118.             activationKey = input.KeyCode
  119.             keyButton.Text = "Key: " .. activationKey.Name
  120.         else
  121.             activationKey = input.UserInputType
  122.             -- nicer display
  123.             keyButton.Text = "Key: " .. tostring(activationKey):gsub("Enum.UserInputType.", "")
  124.         end
  125.     end
  126. end)
  127.  
  128. -- Range controls
  129. local leftArrow = Instance.new("TextButton", Frame)
  130. leftArrow.Size = UDim2.new(0.18, 0, 0, 25)
  131. leftArrow.Position = UDim2.new(0.05, 0, 0.53, 0)
  132. leftArrow.Text = "<"
  133. leftArrow.BackgroundColor3 = Color3.fromRGB(100, 100, 100)
  134. leftArrow.TextColor3 = Color3.fromRGB(255, 255, 255)
  135.  
  136. local rightArrow = Instance.new("TextButton", Frame)
  137. rightArrow.Size = UDim2.new(0.18, 0, 0, 25)
  138. rightArrow.Position = UDim2.new(0.77, 0, 0.53, 0)
  139. rightArrow.Text = ">"
  140. rightArrow.BackgroundColor3 = Color3.fromRGB(100, 100, 100)
  141. rightArrow.TextColor3 = Color3.fromRGB(255, 255, 255)
  142.  
  143. local rangeLabel = Instance.new("TextLabel", Frame)
  144. rangeLabel.Size = UDim2.new(0.6, 0, 0, 25)
  145. rangeLabel.Position = UDim2.new(0.23, 0, 0.53, 0)
  146. rangeLabel.Text = "Range: " .. circleRadius
  147. rangeLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
  148. rangeLabel.BackgroundTransparency = 1
  149.  
  150. leftArrow.MouseButton1Click:Connect(function()
  151.     circleRadius = math.clamp(circleRadius - 10, 50, 800)
  152.     rangeLabel.Text = "Range: " .. circleRadius
  153.     circle.Radius = circleRadius
  154. end)
  155.  
  156. rightArrow.MouseButton1Click:Connect(function()
  157.     circleRadius = math.clamp(circleRadius + 10, 50, 800)
  158.     rangeLabel.Text = "Range: " .. circleRadius
  159.     circle.Radius = circleRadius
  160. end)
  161.  
  162. -- Sensitivity dropdown
  163. local sensitivityButton = Instance.new("TextButton", Frame)
  164. sensitivityButton.Size = UDim2.new(0.9, 0, 0, 30)
  165. sensitivityButton.Position = UDim2.new(0.05, 0, 0.63, 0)
  166. sensitivityButton.Text = "Sensitivity: Smooth"
  167. sensitivityButton.BackgroundColor3 = Color3.fromRGB(70, 70, 70)
  168. sensitivityButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  169.  
  170. local sensitivityOptions = {Slow = 0.05, Smooth = 0.15, Fast = 1}
  171. local currentSense = "Smooth"
  172.  
  173. sensitivityButton.MouseButton1Click:Connect(function()
  174.     if currentSense == "Slow" then
  175.         currentSense = "Smooth"
  176.     elseif currentSense == "Smooth" then
  177.         currentSense = "Fast"
  178.     else
  179.         currentSense = "Slow"
  180.     end
  181.     sensitivityButton.Text = "Sensitivity: " .. currentSense
  182.     smoothness = sensitivityOptions[currentSense]
  183. end)
  184.  
  185. -- Aim part selector UI (Head / Torso / Random)
  186. local aimLabel = Instance.new("TextLabel", Frame)
  187. aimLabel.Size = UDim2.new(0.9, 0, 0, 20)
  188. aimLabel.Position = UDim2.new(0.05, 0, 0.75, 0)
  189. aimLabel.Text = "Aim Part: " .. aimPartOption
  190. aimLabel.TextColor3 = Color3.fromRGB(255,255,255)
  191. aimLabel.BackgroundTransparency = 1
  192.  
  193. local aimCycleButton = Instance.new("TextButton", Frame)
  194. aimCycleButton.Size = UDim2.new(0.9, 0, 0, 24)
  195. aimCycleButton.Position = UDim2.new(0.05, 0, 0.79, 0)
  196. aimCycleButton.Text = "Cycle Aim Part"
  197. aimCycleButton.BackgroundColor3 = Color3.fromRGB(70,70,70)
  198. aimCycleButton.TextColor3 = Color3.fromRGB(255,255,255)
  199.  
  200. aimCycleButton.MouseButton1Click:Connect(function()
  201.     if aimPartOption == "Head" then
  202.         aimPartOption = "Torso"
  203.     elseif aimPartOption == "Torso" then
  204.         aimPartOption = "Random"
  205.     else
  206.         aimPartOption = "Head"
  207.     end
  208.     aimLabel.Text = "Aim Part: " .. aimPartOption
  209. end)
  210.  
  211. -- ESP toggle button
  212. local espButton = Instance.new("TextButton", Frame)
  213. espButton.Size = UDim2.new(0.45, 0, 0, 26)
  214. espButton.Position = UDim2.new(0.05, 0, 0.9, 0)
  215. espButton.Text = "ESP: OFF"
  216. espButton.BackgroundColor3 = Color3.fromRGB(255,60,60)
  217. espButton.TextColor3 = Color3.fromRGB(255,255,255)
  218.  
  219. espButton.MouseButton1Click:Connect(function()
  220.     espEnabled = not espEnabled
  221.     if espEnabled then
  222.         espButton.Text = "ESP: ON"
  223.         espButton.BackgroundColor3 = Color3.fromRGB(0,200,100)
  224.     else
  225.         espButton.Text = "ESP: OFF"
  226.         espButton.BackgroundColor3 = Color3.fromRGB(255,60,60)
  227.         -- remove all ESP GUIs
  228.         for pl, obj in pairs(playerESPs) do
  229.             if obj.gui then obj.gui:Destroy() end
  230.         end
  231.         playerESPs = {}
  232.     end
  233. end)
  234.  
  235. -- Team ESP toggle
  236. local teamEspButton = Instance.new("TextButton", Frame)
  237. teamEspButton.Size = UDim2.new(0.45, 0, 0, 26)
  238. teamEspButton.Position = UDim2.new(0.52, 0, 0.9, 0)
  239. teamEspButton.Text = "Team ESP: OFF"
  240. teamEspButton.BackgroundColor3 = Color3.fromRGB(70,70,70)
  241. teamEspButton.TextColor3 = Color3.fromRGB(255,255,255)
  242.  
  243. teamEspButton.MouseButton1Click:Connect(function()
  244.     teamEspEnabled = not teamEspEnabled
  245.     if teamEspEnabled then
  246.         teamEspButton.Text = "Team ESP: ON"
  247.         teamEspButton.BackgroundColor3 = Color3.fromRGB(0,200,100)
  248.     else
  249.         teamEspButton.Text = "Team ESP: OFF"
  250.         teamEspButton.BackgroundColor3 = Color3.fromRGB(70,70,70)
  251.     end
  252. end)
  253.  
  254. --// Helpers
  255.  
  256. -- find appropriate aiming part name in a character (tries requested, falls back)
  257. local function findAimPartInCharacter(character, wantPartName)
  258.     if not character then return nil end
  259.     if wantPartName == "Head" then
  260.         return character:FindFirstChild("Head")
  261.     elseif wantPartName == "Torso" then
  262.         -- prefer HumanoidRootPart, then Torso
  263.         return character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("Torso") or character:FindFirstChild("UpperTorso") or character:FindFirstChild("LowerTorso")
  264.     else
  265.         -- Random choice between Head and Torso
  266.         local choice = aimCandidates[math.random(1, #aimCandidates)]
  267.         return findAimPartInCharacter(character, choice)
  268.     end
  269. end
  270.  
  271. local function isPartValid(p)
  272.     if not p then return false end
  273.     if not p:IsDescendantOf(workspace) then return false end
  274.     local model = p:FindFirstAncestorOfClass("Model")
  275.     if not model then return false end
  276.     local humanoid = model:FindFirstChildOfClass("Humanoid")
  277.     if not humanoid then return false end
  278.     if humanoid.Health <= 0 then return false end
  279.     return true
  280. end
  281.  
  282. -- get closest part to mouse within circleRadius using aimPartOption logic
  283. local function getClosestToMouse()
  284.     local closest, dist = nil, circleRadius
  285.     local mousePos = UserInputService:GetMouseLocation()
  286.  
  287.     for _, otherPlayer in ipairs(Players:GetPlayers()) do
  288.         if otherPlayer ~= player and otherPlayer.Character then
  289.             local part = findAimPartInCharacter(otherPlayer.Character, aimPartOption)
  290.             if part then
  291.                 local screenPoint, onScreen = camera:WorldToViewportPoint(part.Position)
  292.                 if onScreen then
  293.                     local mag = (Vector2.new(screenPoint.X, screenPoint.Y) - mousePos).Magnitude
  294.                     if mag < dist then
  295.                         dist = mag
  296.                         closest = part
  297.                     end
  298.                 end
  299.             end
  300.         end
  301.     end
  302.  
  303.     return closest
  304. end
  305.  
  306. -- Acquire best target
  307. local function acquireTarget()
  308.     local p = getClosestToMouse()
  309.     if isPartValid(p) then
  310.         target = p
  311.         return true
  312.     end
  313.     target = nil
  314.     return false
  315. end
  316.  
  317. local function clearTarget()
  318.     target = nil
  319. end
  320.  
  321. -- Create BillboardGui ESP for a player's character
  322. local function createESP(playerObj)
  323.     if not playerObj or not playerObj.Character then return nil end
  324.     local char = playerObj.Character
  325.     if playerESPs[playerObj] and playerESPs[playerObj].gui then
  326.         return playerESPs[playerObj]
  327.     end
  328.  
  329.     local head = char:FindFirstChild("Head")
  330.     local root = char:FindFirstChild("HumanoidRootPart") or char:FindFirstChild("Torso")
  331.     local attachPart = head or root
  332.     if not attachPart then return nil end
  333.  
  334.     -- BillboardGui
  335.     local billboard = Instance.new("BillboardGui")
  336.     billboard.Name = "ESP_Billboard"
  337.     billboard.Adornee = attachPart
  338.     billboard.Size = UDim2.new(0, 120, 0, 48)
  339.     billboard.AlwaysOnTop = true
  340.     billboard.MaxDistance = 1000
  341.     billboard.Parent = ScreenGui
  342.  
  343.     local frame = Instance.new("Frame", billboard)
  344.     frame.Size = UDim2.new(1,0,1,0)
  345.     frame.BackgroundTransparency = 1
  346.  
  347.     local nameLabel = Instance.new("TextLabel", frame)
  348.     nameLabel.Size = UDim2.new(1,0,0.6,0)
  349.     nameLabel.Position = UDim2.new(0,0,0,0)
  350.     nameLabel.BackgroundTransparency = 1
  351.     nameLabel.TextStrokeTransparency = 0
  352.     nameLabel.TextStrokeColor3 = Color3.new(0,0,0)
  353.     nameLabel.Text = playerObj.Name
  354.     nameLabel.Font = Enum.Font.SourceSansBold
  355.     nameLabel.TextSize = 14
  356.     nameLabel.TextColor3 = defaultESPColor
  357.  
  358.     local distLabel = Instance.new("TextLabel", frame)
  359.     distLabel.Size = UDim2.new(1,0,0.4,0)
  360.     distLabel.Position = UDim2.new(0,0,0.6,0)
  361.     distLabel.BackgroundTransparency = 1
  362.     distLabel.Text = ""
  363.     distLabel.Font = Enum.Font.SourceSans
  364.     distLabel.TextSize = 12
  365.     distLabel.TextColor3 = defaultESPColor
  366.  
  367.     playerESPs[playerObj] = {
  368.         gui = billboard,
  369.         nameLabel = nameLabel,
  370.         distLabel = distLabel,
  371.         attachedPart = attachPart
  372.     }
  373.     return playerESPs[playerObj]
  374. end
  375.  
  376. -- Remove ESP for player
  377. local function removeESP(playerObj)
  378.     if playerESPs[playerObj] then
  379.         if playerESPs[playerObj].gui then
  380.             playerESPs[playerObj].gui:Destroy()
  381.         end
  382.         playerESPs[playerObj] = nil
  383.     end
  384. end
  385.  
  386. -- Update ESP colors and distance
  387. local function updateESPForPlayer(playerObj)
  388.     local data = playerESPs[playerObj]
  389.     if not data or not data.attachedPart then return end
  390.     local char = playerObj.Character
  391.     if not char then removeESP(playerObj) return end
  392.  
  393.     local root = player.Character and (player.Character:FindFirstChild("HumanoidRootPart") or player.Character:FindFirstChild("Torso"))
  394.     local dist = root and (root.Position - camera.CFrame.Position).Magnitude or 0
  395.     data.distLabel.Text = string.format("%.0f stud", dist)
  396.  
  397.     local color = defaultESPColor
  398.     if teamEspEnabled and playerObj.Team and playerObj.TeamColor then
  399.         -- TeamColor is BrickColor; convert to Color3
  400.         color = playerObj.TeamColor.Color
  401.     end
  402.     data.nameLabel.TextColor3 = color
  403.     data.distLabel.TextColor3 = color
  404. end
  405.  
  406. -- Ensure ESP exists/cleared for all players (constantly called)
  407. local function refreshAllESP()
  408.     if not espEnabled then return end
  409.     for _, pl in ipairs(Players:GetPlayers()) do
  410.         if pl ~= player and pl.Character and pl.Character:FindFirstChildOfClass("Humanoid") and pl.Character:FindFirstChild("Humanoid").Health > 0 then
  411.             if not playerESPs[pl] then
  412.                 createESP(pl)
  413.             end
  414.         else
  415.             removeESP(pl)
  416.         end
  417.     end
  418. end
  419.  
  420. -- Connect player join/leave to maintain ESP
  421. Players.PlayerAdded:Connect(function(pl)
  422.     -- create esp when they spawn if ESP enabled
  423.     pl.CharacterAdded:Connect(function()
  424.         if espEnabled then
  425.             -- slight delay for parts to exist
  426.             wait(0.05)
  427.             createESP(pl)
  428.         end
  429.     end)
  430. end)
  431.  
  432. Players.PlayerRemoving:Connect(function(pl)
  433.     removeESP(pl)
  434. end)
  435.  
  436. -- Also respond to characters added/removed to create/destroy ESP
  437. for _, pl in ipairs(Players:GetPlayers()) do
  438.     pl.CharacterAdded:Connect(function()
  439.         if espEnabled then
  440.             wait(0.05)
  441.             createESP(pl)
  442.         end
  443.     end)
  444. end
  445.  
  446. --// Update Circle Position
  447. RunService.RenderStepped:Connect(function()
  448.     local mousePos = UserInputService:GetMouseLocation()
  449.     circle.Position = Vector2.new(mousePos.X, mousePos.Y)
  450. end)
  451.  
  452. --// Aimbot Loop
  453. RunService.RenderStepped:Connect(function()
  454.     -- Keep ESP updated constantly
  455.     if espEnabled then
  456.         refreshAllESP()
  457.         for pl, _ in pairs(playerESPs) do
  458.             updateESPForPlayer(pl)
  459.         end
  460.     end
  461.  
  462.     if not aimbotEnabled then return end
  463.  
  464.     if aimbotMode == "Hold" then
  465.         if holdingKey then
  466.             local targetPart = getClosestToMouse()
  467.             if targetPart then
  468.                 local targetPos = targetPart.Position
  469.                 local newCFrame = CFrame.new(camera.CFrame.Position, targetPos)
  470.                 camera.CFrame = camera.CFrame:Lerp(newCFrame, smoothness)
  471.             end
  472.         end
  473.     else -- Toggle mode
  474.         if toggleActive then
  475.             if isPartValid(target) then
  476.                 local targetPos = target.Position
  477.                 local newCFrame = CFrame.new(camera.CFrame.Position, targetPos)
  478.                 camera.CFrame = camera.CFrame:Lerp(newCFrame, smoothness)
  479.             else
  480.                 -- target died or invalid -> try to acquire new one automatically
  481.                 if not acquireTarget() then
  482.                     -- no valid target currently; keep toggleActive true and keep trying next frames
  483.                 end
  484.             end
  485.         end
  486.     end
  487. end)
  488.  
  489. --// Input handling
  490. local function matchesActivation(input)
  491.     -- Activation key can be KeyCode or UserInputType
  492.     if typeof(activationKey) == "EnumItem" then
  493.         -- If it's a KeyCode
  494.         if activationKey.EnumType == Enum.KeyCode then
  495.             return input.KeyCode == activationKey
  496.         else
  497.             return input.UserInputType == activationKey
  498.         end
  499.     else
  500.         return (input.UserInputType == activationKey or input.KeyCode == activationKey)
  501.     end
  502. end
  503.  
  504. UserInputService.InputBegan:Connect(function(input, gameProcessed)
  505.     if gameProcessed then return end
  506.     if waitingForKey and not gameProcessed then return end
  507.  
  508.     if matchesActivation(input) then
  509.         if aimbotMode == "Hold" then
  510.             holdingKey = true
  511.         else
  512.             -- Toggle mode: flip toggleActive and acquire target if turning on
  513.             toggleActive = not toggleActive
  514.             if toggleActive then
  515.                 -- If aimPartOption == Random, we might pick a part per acquireTarget call; acquireTarget uses findAimPartInCharacter which handles Random
  516.                 acquireTarget()
  517.             else
  518.                 clearTarget()
  519.             end
  520.         end
  521.     end
  522. end)
  523.  
  524. UserInputService.InputEnded:Connect(function(input)
  525.     if matchesActivation(input) then
  526.         if aimbotMode == "Hold" then
  527.             holdingKey = false
  528.         else
  529.             -- For Toggle mode we DO NOT clear the target here (keeps locked until they die or you toggle off)
  530.         end
  531.     end
  532. end)
  533.  
  534. -- Clear target on player leave or local character removal
  535. Players.PlayerRemoving:Connect(function(p)
  536.     if target and target:FindFirstAncestorOfClass("Model") == p.Character then
  537.         clearTarget()
  538.     end
  539. end)
  540.  
  541. player.CharacterRemoving:Connect(function()
  542.     clearTarget()
  543.     toggleActive = false
  544. end)
  545.  
  546. -- Ensure ESP cleans up if we toggle off later
  547. -- (already handled in espButton)
  548.  
  549. -- End of script
Advertisement
Add Comment
Please, Sign In to add comment