Advertisement
Aril4511

Untitled

May 21st, 2025 (edited)
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.39 KB | None | 0 0
  1. local Players = game:GetService("Players")
  2. local UserInputService = game:GetService("UserInputService")
  3. local RunService = game:GetService("RunService")
  4. local LocalPlayer = Players.LocalPlayer
  5. local Camera = workspace.CurrentCamera
  6.  
  7. local Drawing = Drawing or getgenv().Drawing -- Support for exploit Drawing API
  8.  
  9. local Whitelist = {}
  10. local Aimbot = {
  11.     Enable = false,
  12.     TeamCheck = false,
  13.     Fov = false,
  14.     FovRange = 150, -- Default FOV radius in pixels
  15.     FovColor = Color3.fromRGB(255, 255, 0), -- Default FOV circle color
  16.     Predict = false, -- Predict player movement
  17. }
  18. local Target = nil
  19. local AimbotActive = false
  20. local FovCircle = nil
  21.  
  22. local NEAR_TARGET_DISTANCE = 5 -- in meters
  23.  
  24. function Aimbot.AddToWhitelist(name)
  25.     Whitelist[name] = true
  26. end
  27.  
  28. function Aimbot.RemoveFromWhitelist(name)
  29.     Whitelist[name] = nil
  30. end
  31.  
  32. function Aimbot.getWhitelist()
  33.     local list = {}
  34.     for name, _ in pairs(Whitelist) do
  35.         table.insert(list, name)
  36.     end
  37.     return list
  38. end
  39.  
  40. local function IsOnScreen(pos)
  41.     local _, onScreen = Camera:WorldToViewportPoint(pos)
  42.     return onScreen
  43. end
  44.  
  45. local function IsEnemy(player)
  46.     if not player or not player.Team or not LocalPlayer.Team then return true end
  47.     if Aimbot.TeamCheck then
  48.         return player.Team ~= LocalPlayer.Team
  49.     end
  50.     return true
  51. end
  52.  
  53. local function IsInFOV(screenPos)
  54.     if not Aimbot.Fov then return true end
  55.     local mousePos = UserInputService:GetMouseLocation()
  56.     local dist = (Vector2.new(screenPos.X, screenPos.Y) - mousePos).Magnitude
  57.     return dist <= Aimbot.FovRange
  58. end
  59.  
  60. local function GetPlayerInFOV()
  61.     local closest = nil
  62.     local closestDist = math.huge
  63.     for _, player in ipairs(Players:GetPlayers()) do
  64.         if player ~= LocalPlayer and not Whitelist[player.Name] and IsEnemy(player) then
  65.             local char = player.Character
  66.             local head = char and char:FindFirstChild("Head")
  67.             if head and IsOnScreen(head.Position) then
  68.                 local screenPos = Camera:WorldToViewportPoint(head.Position)
  69.                 if IsInFOV(screenPos) then
  70.                     local mousePos = UserInputService:GetMouseLocation()
  71.                     local dist = (Vector2.new(screenPos.X, screenPos.Y) - mousePos).Magnitude
  72.                     if dist < closestDist then
  73.                         closestDist = dist
  74.                         closest = player
  75.                     end
  76.                 end
  77.             end
  78.         end
  79.     end
  80.     return closest
  81. end
  82.  
  83. local function GetNearTarget()
  84.     local closest = nil
  85.     local closestDist = NEAR_TARGET_DISTANCE
  86.     local character = LocalPlayer.Character
  87.     local root = character and character:FindFirstChild("HumanoidRootPart")
  88.     if not root then return nil end
  89.     for _, player in ipairs(Players:GetPlayers()) do
  90.         if player ~= LocalPlayer and not Whitelist[player.Name] and IsEnemy(player) then
  91.             local char = player.Character
  92.             local root2 = char and char:FindFirstChild("HumanoidRootPart")
  93.             if root2 then
  94.                 local dist = (root.Position - root2.Position).Magnitude
  95.                 if dist < closestDist then
  96.                     closestDist = dist
  97.                     closest = player
  98.                 end
  99.             end
  100.         end
  101.     end
  102.     return closest
  103. end
  104.  
  105. local function GetClosestPlayerOnScreen()
  106.     local closest = nil
  107.     local closestDist = math.huge
  108.     for _, player in ipairs(Players:GetPlayers()) do
  109.         if player ~= LocalPlayer and not Whitelist[player.Name] and IsEnemy(player) then
  110.             local char = player.Character
  111.             local head = char and char:FindFirstChild("Head")
  112.             if head and IsOnScreen(head.Position) then
  113.                 local screenPos = Camera:WorldToViewportPoint(head.Position)
  114.                 local mousePos = UserInputService:GetMouseLocation()
  115.                 local dist = (Vector2.new(screenPos.X, screenPos.Y) - mousePos).Magnitude
  116.                 if dist < closestDist then
  117.                     closestDist = dist
  118.                     closest = player
  119.                 end
  120.             end
  121.         end
  122.     end
  123.     return closest
  124. end
  125.  
  126. local function IsTargetValid(player)
  127.     if not player or Whitelist[player.Name] or not IsEnemy(player) then return false end
  128.     local char = player.Character
  129.     local head = char and char:FindFirstChild("Head")
  130.     if not head then return false end
  131.     return IsOnScreen(head.Position)
  132. end
  133.  
  134. -- Smoothing predict movement, not exceeding 1 stud
  135. local lastPredictedPos = nil
  136.  
  137. local function GetPredictedPosition(target)
  138.     local char = target.Character
  139.     if not char then return nil end
  140.     local head = char:FindFirstChild("Head")
  141.     local hrp = char:FindFirstChild("HumanoidRootPart")
  142.     if not head or not hrp then return head and head.Position or nil end
  143.  
  144.     local velocity = hrp.Velocity or Vector3.new(0,0,0)
  145.     local origin = Camera.CFrame.Position
  146.     local distance = (origin - head.Position).Magnitude
  147.  
  148.     local projectileSpeed = 50
  149.     local travelTime = distance / projectileSpeed
  150.  
  151.     local predicted = head.Position + (velocity * travelTime)
  152.  
  153.     -- Smooth: Clamp movement to max 1 stud from last prediction
  154.     if lastPredictedPos then
  155.         local delta = predicted - lastPredictedPos
  156.         if delta.Magnitude > 1 then
  157.             predicted = lastPredictedPos + delta.Unit
  158.         end
  159.     end
  160.     lastPredictedPos = predicted
  161.  
  162.     return predicted
  163. end
  164.  
  165. local function AimAt(player)
  166.     local char = player.Character
  167.     if char then
  168.         local head = char:FindFirstChild("Head")
  169.         if head then
  170.             local aimPos = head.Position
  171.             if Aimbot.Predict then
  172.                 local predicted = GetPredictedPosition(player)
  173.                 if predicted then
  174.                     aimPos = predicted
  175.                 end
  176.             else
  177.                 lastPredictedPos = nil
  178.             end
  179.             Camera.CFrame = CFrame.new(Camera.CFrame.Position, aimPos)
  180.         end
  181.     end
  182. end
  183.  
  184. local function CreateFovCircle()
  185.     if FovCircle then FovCircle:Remove() end
  186.     FovCircle = Drawing.new("Circle")
  187.     FovCircle.Transparency = 1
  188.     FovCircle.Filled = false
  189.     FovCircle.Color = Aimbot.FovColor
  190.     FovCircle.Thickness = 2
  191.     FovCircle.Radius = Aimbot.FovRange
  192.     FovCircle.Visible = false
  193. end
  194.  
  195. local function UpdateFovCircle()
  196.     if not FovCircle then return end
  197.     if Aimbot.Fov and Aimbot.Enable then
  198.         local mousePos = UserInputService:GetMouseLocation()
  199.         FovCircle.Position = mousePos
  200.         FovCircle.Color = Aimbot.FovColor
  201.         FovCircle.Radius = Aimbot.FovRange
  202.         FovCircle.Visible = true
  203.     else
  204.         FovCircle.Visible = false
  205.     end
  206. end
  207.  
  208. function Aimbot.Load()
  209.     if Aimbot._loaded then return end
  210.     Aimbot._loaded = true
  211.  
  212.     CreateFovCircle()
  213.  
  214.     UserInputService.InputBegan:Connect(function(input, processed)
  215.         if input.UserInputType == Enum.UserInputType.MouseButton2 and not processed then
  216.             if not Aimbot.Enable then return end
  217.             AimbotActive = true
  218.  
  219.             -- Prioritas: FOV > NearTarget > ClosestOnScreen
  220.             if Aimbot.Fov then
  221.                 Target = GetPlayerInFOV()
  222.             end
  223.             if not Target then
  224.                 Target = GetNearTarget()
  225.             end
  226.             if not Target then
  227.                 Target = GetClosestPlayerOnScreen()
  228.             end
  229.         end
  230.     end)
  231.     UserInputService.InputEnded:Connect(function(input, processed)
  232.         if input.UserInputType == Enum.UserInputType.MouseButton2 and not processed then
  233.             if not Aimbot.Enable then return end
  234.             AimbotActive = false
  235.             Target = nil
  236.             lastPredictedPos = nil
  237.         end
  238.     end)
  239.  
  240.     RunService.RenderStepped:Connect(function()
  241.         UpdateFovCircle()
  242.         if not Aimbot.Enable then return end
  243.         if AimbotActive then
  244.             if not IsTargetValid(Target) then
  245.                 if Aimbot.Fov then
  246.                     Target = GetPlayerInFOV()
  247.                 end
  248.                 if not Target then
  249.                     Target = GetNearTarget()
  250.                 end
  251.                 if not Target then
  252.                     Target = GetClosestPlayerOnScreen()
  253.                 end
  254.             end
  255.             if Target then
  256.                 AimAt(Target)
  257.             end
  258.         end
  259.     end)
  260. end
  261.  
  262. return Aimbot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement