local Players = game:GetService("Players") local UserInputService = game:GetService("UserInputService") local ReplicatedStorage = game:GetService("ReplicatedStorage") local Workspace = game:GetService("Workspace") local CONFIG = { Players = true, Animals = true, NPCs = true } local Entities = Workspace:FindFirstChild("WORKSPACE_Entities") if not Entities then return end local PlayersFolder = Entities:FindFirstChild("Players") local AnimalsFolder = Entities:FindFirstChild("Animals") local NPCsFolder = Entities:FindFirstChild("NPCs") local localPlayer = Players.LocalPlayer local function getTargetPosition(origin) local camera = workspace.CurrentCamera local mousePos = UserInputService:GetMouseLocation() local character = localPlayer.Character local hrpChar = character and character:FindFirstChild("HumanoidRootPart") local charPos = hrpChar and hrpChar.Position or origin local charLook = hrpChar and hrpChar.CFrame.LookVector or camera.CFrame.LookVector local closestDist = math.huge local targetPos = nil local function processTarget(part, aimPosition) if not part or not aimPosition then return end local toTarget = (aimPosition - charPos).Unit if charLook:Dot(toTarget) > 0 then local screenPos, onScreen = camera:WorldToScreenPoint(aimPosition) if onScreen and screenPos.Z > 0 then local dist = (Vector2.new(screenPos.X, screenPos.Y) - mousePos).Magnitude if dist < closestDist then closestDist = dist targetPos = aimPosition end end end end if CONFIG.Players and PlayersFolder then for _, model in ipairs(PlayersFolder:GetChildren()) do if model ~= character then local hrp = model:FindFirstChild("HumanoidRootPart") if hrp then local aimPos local head = model:FindFirstChild("Head") if head then aimPos = head.Position - Vector3.new(0, 1, 0) else aimPos = hrp.Position end processTarget(hrp, aimPos) end end end end if CONFIG.Animals and AnimalsFolder then for _, model in ipairs(AnimalsFolder:GetChildren()) do if model:IsA("Model") then local hrp = model:FindFirstChild("HumanoidRootPart") if hrp then processTarget(hrp, hrp.Position) end end end end if CONFIG.NPCs and NPCsFolder then for _, descendant in ipairs(NPCsFolder:GetDescendants()) do if descendant:IsA("Model") then local hrp = descendant:FindFirstChild("HumanoidRootPart") if hrp then processTarget(hrp, hrp.Position) end end end end if closestDist > 1000 then return nil end return targetPos end local ProjectileHandler = require(ReplicatedStorage.SharedModules.World.ProjectileHandler) local oldGetSpread = ProjectileHandler.GetProjectileSpread ProjectileHandler.GetProjectileSpread = function(self, projectileType, projectileParams, info, numProjectiles) if info and info.origin then local targetPos = getTargetPosition(info.origin) if targetPos then local newDir = (targetPos - info.origin).Unit info.direction = newDir end end return oldGetSpread(self, projectileType, projectileParams, info, numProjectiles) end local oldInit = ProjectileHandler.InitProjectiles ProjectileHandler.InitProjectiles = function(self, projectileType, projectileParams, info, callback) if info and info.origin then local targetPos = getTargetPosition(info.origin) if targetPos then local newDir = (targetPos - info.origin).Unit info.direction = newDir end end return oldInit(self, projectileType, projectileParams, info, callback) end