This document defines functions to find the nearest player to the local player and modify chat messages to include information about the nearest player. It gets the local player object and finds the send function used to send chat messages. It then defines a function to find the nearest player by comparing distances between players. Finally, it hooks the send function to modify chat arguments when a message is sent, adding the nearest player and their character/head if a player is near.
This document defines functions to find the nearest player to the local player and modify chat messages to include information about the nearest player. It gets the local player object and finds the send function used to send chat messages. It then defines a function to find the nearest player by comparing distances between players. Finally, it hooks the send function to modify chat arguments when a message is sent, adding the nearest player and their character/head if a player is near.
This document defines functions to find the nearest player to the local player and modify chat messages to include information about the nearest player. It gets the local player object and finds the send function used to send chat messages. It then defines a function to find the nearest player by comparing distances between players. Finally, it hooks the send function to modify chat arguments when a message is sent, adding the nearest player and their character/head if a player is near.
local players,fireFunction = game:GetService('Players')
local plr = players.LocalPlayer
for i,v in pairs(getgc(true)) do
if type(v) == 'table' and rawget(v,'send') then fireFunction = v.send end end
local function near()
local mag = math.huge local near for i,v in pairs(players:GetPlayers()) do if v ~= plr and v.Character and v.Character:FindFirstChild('Head') then local nMag = (plr.Character.HumanoidRootPart.Position - v.Character.HumanoidRootPart.Position).Magnitude if (nMag < mag) then mag = nMag near = v end end end return near end
local sendHook; sendHook = hookfunction(fireFunction,function(...)
local args = {...} if #args > 3 and near() then args[3] = near().Character args[4] = near().Character.Head args[5] = near().Character.Head.Position end return sendHook(unpack(args)) end)