This document contains code that modifies the game's metatable to intercept calls to FindPartOnRayWithIgnoreList. It gets the closest player's character and sets the ray direction to point from the camera to the closest player's head, to prioritize hitting that player when casting rays.
This document contains code that modifies the game's metatable to intercept calls to FindPartOnRayWithIgnoreList. It gets the closest player's character and sets the ray direction to point from the camera to the closest player's head, to prioritize hitting that player when casting rays.
This document contains code that modifies the game's metatable to intercept calls to FindPartOnRayWithIgnoreList. It gets the closest player's character and sets the ray direction to point from the camera to the closest player's head, to prioritize hitting that player when casting rays.
game:GetService("Players") local LocalPlayer = game:GetService("Players").LocalPlayer local function GetClosestPlayer() local ClosestPlayer = nil local FarthestDistance = math.huge for i, v in pairs(Players.GetPlayers(Players)) do if v ~= LocalPlayer and v.Character and v.Character.FindFirstChild(v.Character, "HumanoidRootPart") then local DistanceFromPlayer = (LocalPlayer.Character.HumanoidRootPart.Position - v.Character.HumanoidRootPart.Position).Magnitude if DistanceFromPlayer < FarthestDistance then FarthestDistance = DistanceFromPlayer ClosestPlayer = v end end end if ClosestPlayer then return ClosestPlayer end end local GameMetaTable = getrawmetatable(game) local OldGameMetaTableNamecall = GameMetaTable.__namecall setreadonly(GameMetaTable, false) GameMetaTable.__namecall = newcclosure(function(object, ...) local NamecallMethod = getnamecallmethod() local Arguments = {...} if tostring(NamecallMethod) == "FindPartOnRayWithIgnoreList" then local ClosestPlayer = GetClosestPlayer() if ClosestPlayer and ClosestPlayer.Character then Arguments[1] = Ray.new(Camera.CFrame.Position, (ClosestPlayer.Character.Head.Position - Camera.CFrame.Position).Unit * (Camera.CFrame.Position - ClosestPlayer.Character.Head.Position).Magnitude) end end return OldGameMetaTableNamecall(object, unpack(Arguments)) end) setreadonly(GameMetaTable, true)