local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local Workspace = game:GetService("Workspace") local UserInputService = game:GetService("UserInputService") local RunService = game:GetService("RunService") local GameCommonMethod = require(ReplicatedStorage:WaitForChild("ModuleScript"):WaitForChild("GameCommonMethod")) local oldRaycast = GameCommonMethod.Raycast local function isAlive(character) local humanoid = character and character:FindFirstChildOfClass("Humanoid") return humanoid and humanoid.Health > 0 end local function getTargetPart(character) return character:FindFirstChild("Head") or character:FindFirstChild("HumanoidRootPart") or character:FindFirstChild("Torso") end GameCommonMethod.Raycast = function(origin, direction, filter) local localPlayer = Players.LocalPlayer if filter == GameCommonMethod.DIYBlackRay and type(filter.FilterDescendantsInstances) == "table" and filter.FilterDescendantsInstances[1] == localPlayer.Character then local camera = Workspace.CurrentCamera local mousePos = UserInputService:GetMouseLocation() local maxDist = direction.Magnitude local bestTarget = nil local bestScreenDist = math.huge for _, child in ipairs(Workspace.Player:GetChildren()) do if child:IsA("Model") then if child == localPlayer.Character then continue end local head = child:FindFirstChild("Head") if not head then continue end if isAlive(child) or not child:FindFirstChildOfClass("Humanoid") then local isPlayer = Players:GetPlayerFromCharacter(child) if isPlayer and localPlayer.Team and isPlayer.Team and localPlayer.Team == isPlayer.Team then continue end local headScreenPos, onScreen = camera:WorldToScreenPoint(head.Position) if not onScreen then continue end local screenDist = (Vector2.new(headScreenPos.X, headScreenPos.Y) - mousePos).Magnitude if screenDist < bestScreenDist then local directionToTarget = (head.Position - origin) local dist = directionToTarget.Magnitude if dist <= maxDist then bestScreenDist = screenDist bestTarget = head end end end end end if bestTarget then local newDirection = (bestTarget.Position - origin).Unit * maxDist return oldRaycast(origin, newDirection, filter) end end return oldRaycast(origin, direction, filter) end