local Players = game:GetService("Players") local Workspace = game:GetService("Workspace") local RunService = game:GetService("RunService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local UserInputService = game:GetService("UserInputService") local LocalPlayer = Players.LocalPlayer local ProjectileController = require(ReplicatedStorage.Modules.Client.Controllers.ProjectileController) local Camera = workspace.CurrentCamera local Tracer = Drawing.new("Line") Tracer.Visible = false Tracer.Thickness = 1 Tracer.Color = Color3.fromRGB(255, 255, 255) local function getClosestToMouse() local mouseLocation = UserInputService:GetMouseLocation() local closestPart = nil local closestScreenDistance = math.huge for _, obj in ipairs(Workspace:GetChildren()) do if obj:IsA("Model") and obj ~= LocalPlayer.Character and obj:FindFirstChild("Humanoid") then local humanoid = obj.Humanoid if humanoid and humanoid.Health > 0 then local rootPart = obj:FindFirstChild("HumanoidRootPart") if rootPart then local screenPos, onScreen = Camera:WorldToViewportPoint(rootPart.Position) if onScreen then local screenDistance = (Vector2.new(screenPos.X, screenPos.Y) - Vector2.new(mouseLocation.X, mouseLocation.Y)).Magnitude if screenDistance < closestScreenDistance then closestScreenDistance = screenDistance closestPart = rootPart end end end end end end return closestPart end local originalFire = ProjectileController.Fire ProjectileController.Fire = function(self, weaponId, origin, direction, ...) local targetPart = getClosestToMouse() if targetPart then local localCharacter = LocalPlayer.Character if localCharacter and localCharacter:FindFirstChild("HumanoidRootPart") then local originPos = localCharacter.HumanoidRootPart.Position local targetPos = targetPart.Position local newDirection = (targetPos - originPos).Unit return originalFire(self, weaponId, origin, newDirection, ...) end end return originalFire(self, weaponId, origin, direction, ...) end RunService.RenderStepped:Connect(function() local targetPart = getClosestToMouse() end)