scripercory1

Arensal Slient Aim

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