KeyyToWavyy

Untitled

Apr 8th, 2023
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. local uis = game:GetService("UserInputService")
  2. local cam = game:GetService("Workspace").CurrentCamera
  3. local ts = game:GetService("TweenService")
  4. local plr = game:GetService("Players").LocalPlayer
  5. local zombies = game:GetService("Workspace").Zombies
  6.  
  7. local function getClosestSilent()
  8. local closestDist = math.huge
  9. local closestPlr = nil
  10. for _, v in next, zombies.GetChildren(zombies) do
  11. if game.FindFirstChild(v, "Humanoid") and v.Humanoid.Health > 0 then
  12. local vector, onScreen = cam.worldToScreenPoint(cam, game.WaitForChild(v, "Head", math.huge).Position)
  13. local dist = (Vector2.new(uis.GetMouseLocation(uis).X, uis.GetMouseLocation(uis).Y) - Vector2.new(vector.X, vector.Y)).Magnitude
  14. if dist < closestDist and onScreen then
  15. closestDist = dist
  16. closestPlr = v
  17. end
  18. end
  19. end
  20. return closestPlr
  21. end
  22.  
  23. local namecall;
  24. namecall = hookmetamethod(game, "__namecall", function(Self, ...)
  25. if not checkcaller() and tostring(getcallingscript()) == "Framework" and string.lower(getnamecallmethod()) == "findpartonraywithignorelist" then
  26. local args = {...}
  27. local closest = getClosestSilent()
  28. if closest then
  29. local origin = args[1].Origin
  30. args[1] = Ray.new(origin, closest.Head.Position - origin)
  31. end
  32. return namecall(Self, unpack(args))
  33. end
  34. return namecall(Self, ...)
  35. end)
Add Comment
Please, Sign In to add comment