Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Universal Aimlock, Created: 15.8.2024, Updated: 15.11.2024,
- -- Author: BBD5
- -- Discord: https://discord.gg/xdSgc4xH8S
- -- GitHub: https://github.com/Pikinez
- -- Discription: FFM AIMLOCK - For OmniShield (BBD5)
- local Camera = workspace.CurrentCamera
- local Players = game:GetService("Players")
- local RunService = game:GetService("RunService")
- local UserInputService = game:GetService("UserInputService")
- local TweenService = game:GetService("TweenService")
- local VIM = game:GetService("VirtualInputManager")
- local GuiService = game:GetService("GuiService")
- local LocalPlayer = Players.LocalPlayer
- local Holding = false
- local Target = nil
- _G.AimlockEnabled = true
- _G.TeamCheck = false -- May broken
- _G.AimPart = "Torso" -- Where the aimbot script would lock at. Head, Torso, HumanoidRootPart, etc.
- _G.Sensitivity = 0.2 -- secs (default 0.2)
- _G.FOV = 90 -- Field of View (FOV)
- _G.AimOffset = Vector3.new(0, 0.02, 0) -- Offset to aim slightly below the target's head
- _G.CheckWalls = false -- Enable or disable wall check
- _G.DevDebug = true -- Enable console logs
- local function IsPointVisible(startPosition, endPosition, targetPlayer)
- local direction = (endPosition - startPosition).unit local distance = (endPosition - startPosition).magnitude local ray = Ray.new(startPosition, direction * distance) local raycast = RaycastParams.new()
- raycast.FilterDescendantsInstances = {LocalPlayer.Character, targetPlayer.Character}
- raycast.FilterType = Enum.RaycastFilterType.Exclude
- local result = workspace:Raycast(ray.Origin, ray.Direction, raycast)
- return not result
- end
- local function BBD5()
- local MaximumDistance = math.huge
- local ClosestPlayer = nil
- local CameraDirection = Camera.CFrame.LookVector
- local CameraPosition = Camera.CFrame.Position
- for _, v in next, Players:GetPlayers() do
- if v.Name ~= LocalPlayer.Name then
- if _G.TeamCheck == true then
- if v.Team ~= LocalPlayer.Team then
- if v.Character and v.Character:FindFirstChild("HumanoidRootPart") and v.Character:FindFirstChild("Humanoid") and v.Character.Humanoid.Health > 0 then --Check
- local TargetPosition = v.Character.HumanoidRootPart.Position + _G.AimOffset
- local DirectionToTarget = (TargetPosition - CameraPosition).unit
- local DotProduct = CameraDirection:Dot(DirectionToTarget)
- local Angle = math.acos(DotProduct) * (180 / math.pi)
- if Angle <= _G.FOV / 2 then
- local ScreenPoint = Camera:WorldToScreenPoint(TargetPosition)
- local MousePosition = Vector2.new(UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y)
- local VectorDistance = (MousePosition - Vector2.new(ScreenPoint.X, ScreenPoint.Y)).Magnitude
- if VectorDistance < MaximumDistance then
- if _G.CheckWalls then
- if IsPointVisible(CameraPosition, TargetPosition, v) then
- ClosestPlayer = v
- MaximumDistance = VectorDistance
- end
- else
- ClosestPlayer = v
- MaximumDistance = VectorDistance
- end
- end
- end
- end
- end
- else
- if v.Character and v.Character:FindFirstChild("HumanoidRootPart") and v.Character:FindFirstChild("Humanoid") and v.Character.Humanoid.Health > 0 then -- Check again
- local TargetPosition = v.Character.HumanoidRootPart.Position + _G.AimOffset
- local DirectionToTarget = (TargetPosition - CameraPosition).unit
- local DotProduct = CameraDirection:Dot(DirectionToTarget)
- local Angle = math.acos(DotProduct) * (180 / math.pi)
- if Angle <= _G.FOV / 2 then
- local ScreenPoint = Camera:WorldToScreenPoint(TargetPosition)
- local MousePosition = Vector2.new(UserInputService:GetMouseLocation().X, UserInputService:GetMouseLocation().Y)
- local VectorDistance = (MousePosition - Vector2.new(ScreenPoint.X, ScreenPoint.Y)).Magnitude
- if VectorDistance < MaximumDistance then
- if _G.CheckWalls then
- if IsPointVisible(CameraPosition, TargetPosition, v) then
- ClosestPlayer = v
- MaximumDistance = VectorDistance
- end
- else
- ClosestPlayer = v
- MaximumDistance = VectorDistance
- end
- end
- end
- end
- end
- end
- end
- return ClosestPlayer
- end
- local function Debug() if not _G.DevDebug then return end
- if Target and Target.Character then
- local aimPart = Target.Character:FindFirstChild(_G.AimPart)
- local targetName = Target.Name
- local targetPos = aimPart and aimPart.Position or "N/A"
- print(string.format("target: %s | pos: %s", targetName, tostring(targetPos)))
- else print("No target")
- end
- end
- UserInputService.InputBegan:Connect(function(Input)
- if Input.UserInputType == Enum.UserInputType.MouseButton2 then
- Holding = true
- end
- end)
- UserInputService.InputEnded:Connect(function(Input)
- if Input.UserInputType == Enum.UserInputType.MouseButton2 then
- Holding = false
- Target = nil
- end
- end)
- --RENDER(!BE CAREFULL TO EDIT!)
- RunService.RenderStepped:Connect(function()
- if Holding and _G.AimlockEnabled then
- if not Target or not Target.Character or not Target.Character:FindFirstChild(_G.AimPart) or Target.Character.Humanoid.Health == 0 then -- Second Check
- Target = BBD5()
- end
- if Target and Target.Character and Target.Character:FindFirstChild(_G.AimPart) then
- 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()
- end
- Debug()
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement