local Players = game:GetService("Players") local RunService = game:GetService("RunService") local LocalPlayer = Players.LocalPlayer local Mouse = LocalPlayer:GetMouse() local Camera = workspace.CurrentCamera local ReplicatedStorage = game:GetService("ReplicatedStorage") local Managers = ReplicatedStorage.Common.Managers local WeaponManager = require(Managers.WeaponManager) local fov = 150 local fovcircle = Drawing.new("Circle") fovcircle.Thickness = 0.1 fovcircle.Color = Color3.fromRGB(255, 255, 255) fovcircle.Filled = false fovcircle.Transparency = 1 fovcircle.Visible = true fovcircle.Radius = fov RunService.RenderStepped:Connect(function() local viewportSize = Camera.ViewportSize fovcircle.Position = Vector2.new(viewportSize.X / 2, viewportSize.Y / 2) end) local function isVisible(targetPart) local origin = Camera.CFrame.Position local direction = (targetPart.Position - origin).Unit * (targetPart.Position - origin).Magnitude local raycastParams = RaycastParams.new() raycastParams.FilterDescendantsInstances = {LocalPlayer.Character, Camera} raycastParams.FilterType = Enum.RaycastFilterType.Exclude local result = workspace:Raycast(origin, direction, raycastParams) if result and (result.Instance:IsDescendantOf(targetPart.Parent)) then return true end return false end local function getClosestTargetHead() local closestDist = fov local target = nil local viewportCenter = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2) for _, obj in pairs(workspace:GetChildren()) do if obj:IsA("Model") and obj ~= LocalPlayer.Character and obj.Name ~= "Map" and obj.Name ~= "Viewmodel" then local head = obj:FindFirstChild("Head") local hum = obj:FindFirstChildOfClass("Humanoid") if head and hum and hum.Health > 0 then local screenPos, onScreen = Camera:WorldToViewportPoint(head.Position) if onScreen then local dist = (viewportCenter - Vector2.new(screenPos.X, screenPos.Y)).Magnitude if dist < closestDist then if isVisible(head) then closestDist = dist target = head end end end end end end return target end local oldCast oldCast = hookfunction(WeaponManager.cast, function(origin, direction, target, distance, ignoreList, callbacks, isReplication, isLocal, someBool, color) local targetHead = getClosestTargetHead() if targetHead then local newDirection = (targetHead.Position - origin).Unit * distance return oldCast(origin, newDirection, target, distance, ignoreList, callbacks, isReplication, isLocal, someBool, color) end return oldCast(origin, direction, target, distance, ignoreList, callbacks, isReplication, isLocal, someBool, color) end)