Advertisement
BUNBASTER7BLASTER

FFM AIMLOCK [OPEN-SOURCE, GOOD]

Mar 2nd, 2025
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.67 KB | None | 0 0
  1. --Universal Aimlock, Created: 15.8.2024, Updated: 15.11.2024,
  2. -- Author: BBD5
  3. -- Discord: https://discord.gg/xdSgc4xH8S
  4. -- GitHub: https://github.com/Pikinez
  5. -- Discription: FFM AIMLOCK - For OmniShield (BBD5)
  6.  
  7.  
  8. local Camera = workspace.CurrentCamera
  9. local Players = game:GetService("Players")
  10. local RunService = game:GetService("RunService")
  11. local UserInputService = game:GetService("UserInputService")
  12. local TweenService = game:GetService("TweenService")
  13. local VIM = game:GetService("VirtualInputManager")
  14. local GuiService = game:GetService("GuiService")
  15.  
  16. local LocalPlayer = Players.LocalPlayer
  17. local Holding = false
  18. local Target = nil
  19.  
  20. _G.AimlockEnabled = true
  21. _G.TeamCheck = false -- May broken
  22. _G.AimPart = "Torso" -- Where the aimbot script would lock at. Head, Torso, HumanoidRootPart, etc.
  23. _G.Sensitivity = 0.2 -- secs (default 0.2)
  24. _G.FOV = 90 -- Field of View (FOV)
  25. _G.AimOffset = Vector3.new(0, 0.02, 0) -- Offset to aim slightly below the target's head
  26. _G.CheckWalls = false -- Enable or disable wall check
  27. _G.DevDebug = true -- Enable console logs
  28.  
  29. local function IsPointVisible(startPosition, endPosition, targetPlayer)
  30.     local direction = (endPosition - startPosition).unit local distance = (endPosition - startPosition).magnitude local ray = Ray.new(startPosition, direction * distance) local raycast = RaycastParams.new()
  31.     raycast.FilterDescendantsInstances = {LocalPlayer.Character, targetPlayer.Character}
  32.     raycast.FilterType = Enum.RaycastFilterType.Exclude
  33.     local result = workspace:Raycast(ray.Origin, ray.Direction, raycast)
  34.     return not result
  35. end
  36.  
  37.  
  38.  
  39. local function BBD5()
  40.     local MaximumDistance = math.huge
  41.     local ClosestPlayer = nil
  42.  
  43.     local CameraDirection = Camera.CFrame.LookVector
  44.     local CameraPosition = Camera.CFrame.Position
  45.  
  46.     for _, v in next, Players:GetPlayers() do
  47.         if v.Name ~= LocalPlayer.Name then
  48.             if _G.TeamCheck == true then
  49.                 if v.Team ~= LocalPlayer.Team then
  50.                     if v.Character and v.Character:FindFirstChild("HumanoidRootPart") and v.Character:FindFirstChild("Humanoid") and v.Character.Humanoid.Health > 0 then --Check
  51.                         local TargetPosition = v.Character.HumanoidRootPart.Position + _G.AimOffset
  52.                         local DirectionToTarget = (TargetPosition - CameraPosition).unit
  53.                         local DotProduct = CameraDirection:Dot(DirectionToTarget)
  54.                         local Angle = math.acos(DotProduct) * (180 / math.pi)
  55.  
  56.                         if Angle <= _G.FOV / 2 then
  57.                             local ScreenPoint = Camera:WorldToScreenPoint(TargetPosition)
  58.                             local MousePosition = Vector2.new(UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y)
  59.                             local VectorDistance = (MousePosition - Vector2.new(ScreenPoint.X, ScreenPoint.Y)).Magnitude
  60.                        
  61.                             if VectorDistance < MaximumDistance then
  62.                                 if _G.CheckWalls then
  63.                                     if IsPointVisible(CameraPosition, TargetPosition, v) then
  64.                                         ClosestPlayer = v
  65.                                         MaximumDistance = VectorDistance
  66.                                     end
  67.                                 else
  68.                                     ClosestPlayer = v
  69.                                     MaximumDistance = VectorDistance
  70.                                 end
  71.                             end
  72.                         end
  73.                     end
  74.                 end
  75.             else
  76.                 if v.Character and v.Character:FindFirstChild("HumanoidRootPart") and v.Character:FindFirstChild("Humanoid") and v.Character.Humanoid.Health > 0 then -- Check again
  77.                     local TargetPosition = v.Character.HumanoidRootPart.Position + _G.AimOffset
  78.                     local DirectionToTarget = (TargetPosition - CameraPosition).unit
  79.                     local DotProduct = CameraDirection:Dot(DirectionToTarget)
  80.                     local Angle = math.acos(DotProduct) * (180 / math.pi)
  81.  
  82.                     if Angle <= _G.FOV / 2 then
  83.                         local ScreenPoint = Camera:WorldToScreenPoint(TargetPosition)
  84.                         local MousePosition = Vector2.new(UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y)
  85.                         local VectorDistance = (MousePosition - Vector2.new(ScreenPoint.X, ScreenPoint.Y)).Magnitude
  86.                        
  87.                         if VectorDistance < MaximumDistance then
  88.                             if _G.CheckWalls then
  89.                                 if IsPointVisible(CameraPosition, TargetPosition, v) then
  90.                                     ClosestPlayer = v
  91.                                     MaximumDistance = VectorDistance
  92.                                 end
  93.                             else
  94.                                 ClosestPlayer = v
  95.                                 MaximumDistance = VectorDistance
  96.                             end
  97.                         end
  98.                     end
  99.                 end
  100.             end
  101.         end
  102.     end
  103.  
  104.     return ClosestPlayer
  105. end
  106.  
  107.  
  108.  
  109.  
  110.  
  111. local function Debug() if not _G.DevDebug then return end
  112.     if Target and Target.Character then
  113.         local aimPart = Target.Character:FindFirstChild(_G.AimPart)
  114.         local targetName = Target.Name
  115.         local targetPos = aimPart and aimPart.Position or "N/A"
  116.         print(string.format("target: %s | pos: %s", targetName, tostring(targetPos)))
  117.     else print("No target")
  118.     end
  119. end
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126. UserInputService.InputBegan:Connect(function(Input)
  127.     if Input.UserInputType == Enum.UserInputType.MouseButton2 then
  128.         Holding = true
  129.     end
  130. end)
  131.  
  132.  
  133.  
  134.  
  135. UserInputService.InputEnded:Connect(function(Input)
  136.     if Input.UserInputType == Enum.UserInputType.MouseButton2 then
  137.         Holding = false
  138.         Target = nil
  139.        
  140.     end
  141. end)
  142.  
  143.  
  144.  
  145.  
  146. --RENDER(!BE CAREFULL TO EDIT!)
  147.  
  148. RunService.RenderStepped:Connect(function()
  149.     if Holding and _G.AimlockEnabled then
  150.         if not Target or not Target.Character or not Target.Character:FindFirstChild(_G.AimPart) or Target.Character.Humanoid.Health == 0 then -- Second Check
  151.             Target = BBD5()
  152.         end
  153.         if Target and Target.Character and Target.Character:FindFirstChild(_G.AimPart) then
  154.             TweenService:Create(Camera, TweenInfo.new(_G.Sensitivity, Enum.EasingStyle.Sine, Enum.EasingDirection.Out), {CFrame = CFrame.new(Camera.CFrame.Position, Target.Character[_G.AimPart].Position + _G.AimOffset)}):Play()
  155.         end
  156.         Debug()
  157.     end
  158. end)
  159.  
  160.  
  161.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement