Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game.Players
- local LocalPlayer = Players.LocalPlayer
- local GetPlayers = Players.GetPlayers
- local Camera = workspace.CurrentCamera
- local WTSP = Camera.WorldToScreenPoint
- local FindFirstChild = game.FindFirstChild
- local Vector2_new = Vector2.new
- local Mouse = LocalPlayer.GetMouse(LocalPlayer)
- function ClosestChar()
- local Max, Close = math.huge
- for I,V in pairs(GetPlayers(Players)) do
- if V ~= LocalPlayer and V.Team ~= LocalPlayer.Team and V.Character then
- local Head = FindFirstChild(V.Character, "Head")
- if Head then
- local Pos, OnScreen = WTSP(Camera, Head.Position)
- if OnScreen then
- local Dist = (Vector2_new(Pos.X, Pos.Y) - Vector2_new(Mouse.X, Mouse.Y)).Magnitude
- if Dist < Max then
- Max = Dist
- Close = V.Character
- end
- end
- end
- end
- end
- return Close
- end
- local MT = getrawmetatable(game)
- local __namecall = MT.__namecall
- setreadonly(MT, false)
- MT.__namecall = newcclosure(function(self, ...)
- local Method = getnamecallmethod()
- if Method == "FindPartOnRay" and not checkcaller() and tostring(getfenv(0).script) == "GunInterface" then
- local Character = ClosestChar()
- if Character then
- return Character.Head, Character.Head.Position
- end
- end
- return __namecall(self, ...)
- end)
- setreadonly(MT, true)
Add Comment
Please, Sign In to add comment