Advertisement
Guest User

AIMBOT

a guest
Dec 14th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.76 KB | None | 0 0
  1. local plrs = game:GetService("Players")
  2. local TeamBased = true ; local teambasedswitch = "o"
  3. local presskeytoaim = true; local aimkey = "e"
  4. local raycast = false
  5.  
  6. local espupdatetime = 5; autoesp = false
  7.  
  8.  
  9.  
  10. local lockaim = true; local lockangle = 5
  11.  
  12.  
  13.  
  14. --function findwat(folder, what)
  15. --  for i, smth in pairs(folder:GetChildren()) do
  16. --      if string.find(string.lower(tostring(smth)), string.lower(what)) then
  17. --          return smth
  18. --      end
  19. --  end
  20. --end
  21. --
  22. --local plrs = findwat(game, "Players")
  23.  
  24.  
  25.  
  26.  
  27. local Gui = Instance.new("ScreenGui")
  28. local Move = Instance.new("Frame")
  29. local Main = Instance.new("Frame")
  30. local EspStatus = Instance.new("TextLabel")
  31. local st1 = Instance.new("TextLabel")
  32. local st1_2 = Instance.new("TextLabel")
  33. local st1_3 = Instance.new("TextLabel")
  34. local Name = Instance.new("TextLabel")
  35. --Properties:
  36. Gui.Name = "Gui"
  37. Gui.Parent = plrs.LocalPlayer:WaitForChild("PlayerGui")
  38.  
  39. Move.Name = "Move"
  40. Move.Parent = Gui
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. -- Scripts:
  53.  
  54.  
  55. local plrsforaim = {}
  56.  
  57. local lplr = game:GetService("Players").LocalPlayer
  58. Move.Draggable = true
  59. Gui.ResetOnSpawn = false
  60. Gui.Name = "Chat"
  61. Gui.DisplayOrder = 999
  62.  
  63.     Gui.Parent = plrs.LocalPlayer.PlayerGui
  64.  
  65.  
  66. f = {}
  67. local espforlder
  68.  
  69. f.addesp = function()
  70.     --print("ESP ran")
  71.     if espforlder then
  72.     else
  73.         espforlder = Instance.new("Folder")
  74.         espforlder.Parent = game.Workspace.CurrentCamera
  75.     end
  76.     for i, v in pairs(espforlder:GetChildren()) do
  77.         v:Destroy()
  78.     end
  79.     for _, plr in pairs(plrs:GetChildren()) do
  80.         if plr.Character and plr.Character.Humanoid.Health > 0 and plr.Name ~= lplr.Name then
  81.             if TeamBased == true then
  82.                 if plr.Team.Name ~= plrs.LocalPlayer.Team.Name  then
  83.                     local e = espforlder:FindFirstChild(plr.Name)
  84.                     if not e then
  85.                         --print("Added esp for team based")
  86.                         local bill = Instance.new("BillboardGui", espforlder)
  87.                         bill.Name = plr.Name
  88.                         bill.AlwaysOnTop = true
  89.                         bill.Size = UDim2.new(1,0,1,0)
  90.                         bill.Adornee = plr.Character.Head
  91.                         local Frame = Instance.new('Frame',bill)
  92.                         Frame.Active = true
  93.                         Frame.BackgroundColor3 = Color3.new(0/255,255/255,0/255)
  94.                         Frame.BackgroundTransparency = 0
  95.                         Frame.BorderSizePixel = 0
  96.                         Frame.AnchorPoint = Vector2.new(.5, .5)
  97.                         Frame.Position = UDim2.new (0.5,0,0.5,0)
  98.                         Frame.Size = UDim2.new (1,0,1,0)
  99.                         Frame.Rotation = 0
  100.                         plr.Character.Humanoid.Died:Connect(function()
  101.                             bill:Destroy()
  102.                         end)
  103.                     end
  104.                 end
  105.             else
  106.                 local e = espforlder:FindFirstChild(plr.Name)
  107.                 if not e then
  108.                     --print("Added esp")
  109.                     local bill = Instance.new("BillboardGui", espforlder)
  110.                     bill.Name = plr.Name
  111.                     bill.AlwaysOnTop = true
  112.                     bill.Size = UDim2.new(1,0,1,0)
  113.                     bill.Adornee = plr.Character.Head
  114.                     local Frame = Instance.new('Frame',bill)
  115.                     Frame.Active = true
  116.                     Frame.BackgroundColor3 = Color3.new(0/255,255/255,0/255)
  117.                     Frame.BackgroundTransparency = 0
  118.                     Frame.BorderSizePixel = 0
  119.                     Frame.AnchorPoint = Vector2.new(.5, .5)
  120.                     Frame.Position = UDim2.new (0.5,0,0.5,0)
  121.                     Frame.Size = UDim2.new (1,0,1,0)
  122.                     Frame.Rotation = 0
  123.                     plr.Character.Humanoid.Died:Connect(function()
  124.                         bill:Destroy()
  125.                     end)
  126.                 end
  127.             end
  128.            
  129.            
  130.         end
  131.     end
  132. end
  133. local cam = game.Workspace.CurrentCamera
  134.  
  135. local mouse = lplr:GetMouse()
  136. local switch = false
  137. local key = "k"
  138. local aimatpart = nil
  139. mouse.KeyDown:Connect(function(a)
  140.     if a == "t" then
  141.         print("worked1")
  142.         f.addesp()
  143.     elseif a == "u" then
  144.         if raycast == true then
  145.             raycast = false
  146.         else
  147.             raycast = true
  148.         end
  149.     elseif a == "l" then
  150.         if autoesp == false then
  151.             autoesp = true
  152.         else
  153.             autoesp = false
  154.         end
  155.     end
  156.     if a == "j" then
  157.         if mouse.Target then
  158.             mouse.Target:Destroy()
  159.         end
  160.     end
  161.     if a == key then
  162.         if switch == false then
  163.             switch = true
  164.         else
  165.             switch = false
  166.             if aimatpart ~= nil then
  167.                 aimatpart = nil
  168.             end
  169.         end
  170.     elseif a == teambasedswitch then
  171.         if TeamBased == true then
  172.             TeamBased = false
  173.             teambasedstatus.Text = tostring(TeamBased)
  174.         else
  175.             TeamBased = true
  176.             teambasedstatus.Text = tostring(TeamBased)
  177.         end
  178.     elseif a == aimkey then
  179.         if not aimatpart then
  180.             local maxangle = math.rad(20)
  181.             for i, plr in pairs(plrs:GetChildren()) do
  182.                 if plr.Name ~= lplr.Name and plr.Character and plr.Character.Head and plr.Character.Humanoid and plr.Character.Humanoid.Health > 1 then
  183.                     if TeamBased == true then
  184.                         if plr.Team.Name ~= lplr.Team.Name then
  185.                             local an = checkfov(plr.Character.Head)
  186.                             if an < maxangle then
  187.                                 maxangle = an
  188.                                 aimatpart = plr.Character.Head
  189.                             end
  190.                         end
  191.                     else
  192.                         local an = checkfov(plr.Character.Head)
  193.                             if an < maxangle then
  194.                                 maxangle = an
  195.                                 aimatpart = plr.Character.Head
  196.                             end
  197.                             print(plr)
  198.                     end
  199.                     plr.Character.Humanoid.Died:Connect(function()
  200.                         if aimatpart.Parent == plr.Character or aimatpart == nil then
  201.                             aimatpart = nil
  202.                         end
  203.                     end)
  204.                 end
  205.             end
  206.         else
  207.             aimatpart = nil
  208.         end
  209.     end
  210. end)
  211.  
  212. function getfovxyz (p0, p1, deg)
  213.     local x1, y1, z1 = p0:ToOrientation()
  214.     local cf = CFrame.new(p0.p, p1.p)
  215.     local x2, y2, z2 = cf:ToOrientation()
  216.     --local d = math.deg
  217.     if deg then
  218.         --return Vector3.new(d(x1-x2), d(y1-y2), d(z1-z2))
  219.     else
  220.         return Vector3.new((x1-x2), (y1-y2), (z1-z2))
  221.     end
  222. end
  223.  
  224. function getaimbotplrs()
  225.     plrsforaim = {}
  226.     for i, plr in pairs(plrs:GetChildren()) do
  227.         if plr.Character and plr.Character.Humanoid and plr.Character.Humanoid.Health > 0 and plr.Name ~= lplr.Name and plr.Character.Head then
  228.            
  229.             if TeamBased == true then
  230.                 if plr.Team.Name ~= lplr.Team.Name then
  231.                     local cf = CFrame.new(game.Workspace.CurrentCamera.CFrame.p, plr.Character.Head.CFrame.p)
  232.                     local r = Ray.new(cf, cf.LookVector * 10000)
  233.                     local ign = {}
  234.                     for i, v in pairs(plrs.LocalPlayer.Character:GetChildren()) do
  235.                         if v:IsA("BasePart") then
  236.                             table.insert(ign , v)
  237.                         end
  238.                     end
  239.                     local obj = game.Workspace:FindPartOnRayWithIgnoreList(r, ign)
  240.                     if obj.Parent == plr.Character and obj.Parent ~= lplr.Character then
  241.                         table.insert(plrsforaim, obj)
  242.                     end
  243.                 end
  244.             else
  245.                 local cf = CFrame.new(game.Workspace.CurrentCamera.CFrame.p, plr.Character.Head.CFrame.p)
  246.                 local r = Ray.new(cf, cf.LookVector * 10000)
  247.                 local ign = {}
  248.                 for i, v in pairs(plrs.LocalPlayer.Character:GetChildren()) do
  249.                     if v:IsA("BasePart") then
  250.                         table.insert(ign , v)
  251.                     end
  252.                 end
  253.                 local obj = game.Workspace:FindPartOnRayWithIgnoreList(r, ign)
  254.                 if obj.Parent == plr.Character and obj.Parent ~= lplr.Character then
  255.                     table.insert(plrsforaim, obj)
  256.                 end
  257.             end
  258.            
  259.            
  260.         end
  261.     end
  262. end
  263.  
  264. function aimat(part)
  265.     cam.CFrame = CFrame.new(cam.CFrame.p, part.CFrame.p)
  266. end
  267. function checkfov (part)
  268.     local fov = getfovxyz(game.Workspace.CurrentCamera.CFrame, part.CFrame)
  269.     local angle = math.abs(fov.X) + math.abs(fov.Y)
  270.     return angle
  271. end
  272.  
  273. game:GetService("RunService").RenderStepped:Connect(function()
  274.     if aimatpart then
  275.         aimat(aimatpart)
  276.         if aimatpart.Parent == plrs.LocalPlayer.Character then
  277.             aimatpart = nil
  278.         end
  279.     end
  280.    
  281.    
  282. --  if switch == true then
  283. --      local maxangle = 99999
  284. --     
  285. --      --print("Loop")
  286. --      if true and raycast == false then
  287. --          for i, plr in pairs(plrs:GetChildren()) do
  288. --              if plr.Name ~= lplr.Name and plr.Character and plr.Character.Head and plr.Character.Humanoid and plr.Character.Humanoid.Health > 1 then
  289. --                  if TeamBased then
  290. --                      if plr.Team.Name ~= lplr.Team.Name or plr.Team.TeamColor ~= lplr.Team.TeamColor then
  291. --                          local an = checkfov(plr.Character.Head)
  292. --                          if an < maxangle then
  293. --                              maxangle = an
  294. --                              aimatpart = plr.Character.Head
  295. --                              if an < lockangle then
  296. --                                  break
  297. --                              end
  298. --                          end
  299. --                      end
  300. --                  else
  301. --                      local an = checkfov(plr.Character.Head)
  302. --                          if an < maxangle then
  303. --                              maxangle = an
  304. --                              aimatpart = plr.Character.Head
  305. --                              if an < lockangle then
  306. --                                  break
  307. --                              end
  308. --                          end
  309. --                  end
  310. --                 
  311. --                 
  312. --                 
  313. --                 
  314. --              end
  315. --          end
  316. --      elseif raycast == true then
  317. --         
  318. --      end
  319.        
  320.         if raycast == true and switch == false and not aimatpart then
  321.             getaimbotplrs()
  322.             aimatpart = nil
  323.             local maxangle = 999
  324.             for i, v in ipairs(plrsforaim) do
  325.                 if v.Parent ~= lplr.Character then
  326.                     local an = checkfov(v)
  327.                     if an < maxangle and v ~= lplr.Character.Head then
  328.                         maxangle = an
  329.                         aimatpart = v
  330.                         print(v:GetFullName())
  331.                         v.Parent.Humanoid.Died:connect(function()
  332.                             aimatpart = nil
  333.                         end)
  334.                     end
  335.                 end
  336.             end
  337.        
  338.     end
  339. end)
  340. delay(0, function()
  341.     while wait(espupdatetime) do
  342.         if autoesp == true then
  343.             pcall(function()
  344.             f.addesp()
  345.             end)
  346.         end
  347.     end
  348. end)
  349. warn("loaded")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement