Advertisement
KOLBYsssss

silent aim

Feb 26th, 2022
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.95 KB | None | 0 0
  1. --> VARIABLES <--
  2. local plrs = game:GetService("Players")
  3. local plr = plrs.LocalPlayer
  4. local mouse = plr:GetMouse()
  5. local camera = game:GetService("Workspace").CurrentCamera
  6.  
  7. --> FUNCTIONS <--
  8. function notBehindWall(target)
  9. local ray = Ray.new(plr.Character.Head.Position, (target.Position - plr.Character.Head.Position).Unit * 300)
  10. local part, position = game:GetService("Workspace"):FindPartOnRayWithIgnoreList(ray, {plr.Character}, false, true)
  11. if part then
  12. local humanoid = part.Parent:FindFirstChildOfClass("Humanoid")
  13. if not humanoid then
  14. humanoid = part.Parent.Parent:FindFirstChildOfClass("Humanoid")
  15. end
  16. if humanoid and target and humanoid.Parent == target.Parent then
  17. local pos, visible = camera:WorldToScreenPoint(target.Position)
  18. if visible then
  19. return true
  20. end
  21. end
  22. end
  23. end
  24.  
  25. function getPlayerClosestToMouse()
  26. local target = nil
  27. local maxDist = 100
  28. for _,v in pairs(plrs:GetPlayers()) do
  29. if v.Character then
  30. if v.Character:FindFirstChild("Humanoid") and v.Character.Humanoid.Health ~= 0 and v.Character:FindFirstChild("HumanoidRootPart") and v.TeamColor ~= plr.TeamColor then
  31. local pos, vis = camera:WorldToViewportPoint(v.Character.HumanoidRootPart.Position)
  32. local dist = (Vector2.new(mouse.X, mouse.Y) - Vector2.new(pos.X, pos.Y)).magnitude
  33. if dist < maxDist and vis then
  34. local torsoPos = camera:WorldToViewportPoint(v.Character.HumanoidRootPart.Position)
  35. local torsoDist = (Vector2.new(mouse.X, mouse.Y) - Vector2.new(torsoPos.X, torsoPos.Y)).magnitude
  36. local headPos = camera:WorldToViewportPoint(v.Character.Head.Position)
  37. local headDist = (Vector2.new(mouse.X, mouse.Y) - Vector2.new(headPos.X, headPos.Y)).magnitude
  38. if torsoDist > headDist then
  39. if notBehindWall(v.Character.Head) then
  40. target = v.Character.Head
  41. end
  42. else
  43. if notBehindWall(v.Character.HumanoidRootPart) then
  44. target = v.Character.HumanoidRootPart
  45. end
  46. end
  47. maxDist = dist
  48. end
  49. end
  50. end
  51. end
  52. return target
  53. end
  54.  
  55. --> Hooking to the remote <--
  56. local gmt = getrawmetatable(game)
  57. setreadonly(gmt, false)
  58. local oldNamecall = gmt.__namecall
  59.  
  60. gmt.__namecall = newcclosure(function(self, ...)
  61. local Args = {...}
  62. local method = getnamecallmethod()
  63. if tostring(self) == "HitPart" and tostring(method) == "FireServer" then
  64. Args[1] = getPlayerClosestToMouse()
  65. Args[2] = getPlayerClosestToMouse().Position
  66. return self.FireServer(self, unpack(Args))
  67. end
  68. return oldNamecall(self, ...)
  69. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement