local Players = game:GetService("Players") local RunService = game:GetService("RunService") local UserInputService = game:GetService("UserInputService") local LocalPlayer = Players.LocalPlayer local target = { enabled = true, position = nil } local Hooks = {} local function getClosestTarget() local camera = workspace.CurrentCamera local mousePos = UserInputService:GetMouseLocation() local closestDist = math.huge local function checkModel(model) local head = model:FindFirstChild("Head") local hum = model:FindFirstChildOfClass("Humanoid") if not head or not hum or hum.Health <= 0 then return end local screenPos, onScreen = camera:WorldToViewportPoint(head.Position) if not onScreen then return end local dist = (Vector2.new(screenPos.X, screenPos.Y) - mousePos).Magnitude if dist < closestDist then closestDist = dist target.position = head.Position end end for _, player in ipairs(Players:GetPlayers()) do if player == LocalPlayer then continue end local char = player.Character if char and char.Parent == workspace then checkModel(char) end end for _, obj in ipairs(workspace:GetChildren()) do if obj:IsA("Model") and obj.Name:find("BotModel") then checkModel(obj) end end end Hooks.Raycast = hookmetamethod(game, "__namecall", newcclosure(function(self, ...) if not target.enabled or not target.position or getnamecallmethod():lower() ~= "raycast" then return Hooks.Raycast(self, ...) end if typeof(self) ~= "Instance" or self ~= workspace then return Hooks.Raycast(self, ...) end local args = {...} if typeof(args[1]) == "Vector3" then args[2] = (target.position - workspace.CurrentCamera.CFrame.Position).Unit * 500 end return Hooks.Raycast(self, table.unpack(args)) end)) RunService.Heartbeat:Connect(function() if target.enabled then pcall(getClosestTarget) end end)