Advertisement
Guest User

silent aim script

a guest
Jan 24th, 2020
59,422
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 2 2
  1. local localPlayer = game:GetService("Players").LocalPlayer
  2. local mouse = localPlayer:GetMouse()
  3. local teamCheck = true
  4.  
  5. local function getClosestPlayer()
  6. local closestPlayer = nil
  7. local shortestDistance = math.huge
  8.  
  9. for i, v in pairs(game:GetService("Players"):GetPlayers()) do
  10. if v.Name ~= localPlayer.Name then
  11. 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
  12. local magnitude = (v.Character.HumanoidRootPart.Position - localPlayer.Character.HumanoidRootPart.Position).magnitude
  13.  
  14. if magnitude < shortestDistance then
  15. closestPlayer = v
  16. shortestDistance = magnitude
  17. end
  18. 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
  19. local magnitude = (v.Character.HumanoidRootPart.Position - localPlayer.Character.HumanoidRootPart.Position).magnitude
  20.  
  21. if magnitude < shortestDistance then
  22. closestPlayer = v
  23. shortestDistance = magnitude
  24. end
  25. end
  26. end
  27. end
  28.  
  29. return closestPlayer
  30. end
  31.  
  32. game:GetService("UserInputService").InputBegan:Connect(function(input, onGui)
  33. if not onGui and input.KeyCode == Enum.KeyCode.T then
  34. teamCheck = not teamCheck
  35. end
  36. end)
  37.  
  38. local mt = getrawmetatable(game)
  39. local oldIndex = mt.__index
  40. local oldNamecall = mt.__namecall
  41. if setreadonly then setreadonly(mt, false) else make_writeable(mt, true) end
  42. local nameCallMethod = getnamecallmethod or get_namecall_method
  43. local newClose = newcclosure or function(f) return f end
  44.  
  45. mt.__index = newClose(function(t, k)
  46. if t == mouse and tostring(k) == "Hit" then
  47. if getClosestPlayer().Character and getClosestPlayer().Character:FindFirstChild("Head") then
  48. return getClosestPlayer().Character.Head.CFrame
  49. end
  50. end
  51.  
  52. return oldIndex(t, k)
  53. end)
  54.  
  55. mt.__namecall = newClose(function(...)
  56. local method = nameCallMethod()
  57. local args = {...}
  58.  
  59. if tostring(method) == "FindPartOnRayWithIgnoreList" and getClosestPlayer() and getClosestPlayer().Character then
  60. return oldNamecall(args[1], args[2], {game:GetService("Workspace").IgnoreThese, game:GetService("Players").LocalPlayer.Character, game:GetService("Workspace").BuildStuff, game:GetService("Workspace").Map})
  61. end
  62.  
  63. return oldNamecall(...)
  64. end)
  65.  
  66. if setreadonly then setreadonly(mt, true) else make_writeable(mt, false) end
  67.  
  68. local oldFunc
  69.  
  70. oldFunc = hookfunction(workspace.FindPartOnRayWithIgnoreList, function(...)
  71. local args = {...}
  72.  
  73. args[3] = {game:GetService("Workspace").IgnoreThese, game:GetService("Players").LocalPlayer.Character, game:GetService("Workspace").BuildStuff, game:GetService("Workspace").Map}
  74.  
  75. return oldFunc(unpack(args))
  76. end)
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement