CriShoux

counter aim arsenal aim

Oct 6th, 2019
6,064
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. local localPlayer = game:GetService("Players").LocalPlayer
  2. local currentCamera = game:GetService("Workspace").CurrentCamera
  3. local mouse = localPlayer:GetMouse()
  4. local teamCheck = true
  5.  
  6. function getClosestPlayerToCursor() [nonamecall]
  7. local closestPlayer = nil
  8. local shortestDistance = math.huge
  9.  
  10. for i, v in pairs(game:GetService("Players"):GetPlayers()) do
  11. if v.Name ~= localPlayer.Name then
  12. if v.Character and v.Character:FindFirstChild("Humanoid") and v.Character.Humanoid.Health ~= 0 and v.Character:FindFirstChild("HumanoidRootPart") and v.Character:FindFirstChild("Head") and teamCheck and v.Team ~= localPlayer.Team then
  13. local pos = currentCamera:WorldToViewportPoint(v.Character.HumanoidRootPart.Position)
  14. local magnitude = (Vector2.new(pos.X, pos.Y) - Vector2.new(mouse.X, mouse.Y)).magnitude
  15.  
  16. if magnitude < shortestDistance then
  17. closestPlayer = v
  18. shortestDistance = magnitude
  19. end
  20. elseif v.Character and v.Character:FindFirstChild("Humanoid") and v.Character.Humanoid.Health ~= 0 and v.Character:FindFirstChild("HumanoidRootPart") and v.Character:FindFirstChild("Head") and not teamCheck then
  21. local pos = currentCamera:WorldToViewportPoint(v.Character.HumanoidRootPart.Position)
  22. local magnitude = (Vector2.new(pos.X, pos.Y) - Vector2.new(mouse.X, mouse.Y)).magnitude
  23.  
  24. if magnitude < shortestDistance then
  25. closestPlayer = v
  26. shortestDistance = magnitude
  27. end
  28. end
  29. end
  30. end
  31.  
  32. return closestPlayer or localPlayer
  33. end
  34.  
  35. game:GetService("UserInputService").InputBegan:Connect(function(input, onGui)
  36. if not onGui and input.KeyCode == Enum.KeyCode.T then
  37. teamCheck = not teamCheck
  38. end
  39. end)
  40.  
  41. local mt = getrawmetatable(game)
  42. local oldNamecall = mt.__namecall
  43. if setreadonly then setreadonly(mt, false) else make_writeable(mt, true) end
  44. local namecallMethod = getnamecallmethod or get_namecall_method
  45. local newClose = newcclosure or function(f) return f end
  46.  
  47. mt.__namecall = newClose(function(...) [nonamecall]
  48. local method = namecallMethod()
  49. local args = {...}
  50.  
  51. if tostring(method) == "FireServer" and tostring(args[1]) == "HitPart" then
  52. args[2] = getClosestPlayerToCursor().Character.Head
  53. args[3] = getClosestPlayerToCursor().Character.Head.Position
  54.  
  55. return oldNamecall(unpack(args))
  56. end
  57.  
  58. return oldNamecall(...)
  59. end)
  60.  
  61. if setreadonly then setreadonly(mt, true) else make_writeable(mt, false) end
Add Comment
Please, Sign In to add comment