SHARE
TWEET

pf aimbot

dkg_yt Dec 6th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. local getclosestPlayer = function() -- Checks the closest player based on Hypotenuse.
  3.    local plrs, v = safe.Players:GetPlayers()
  4.    local maxdist = 75
  5.    local dist = math.huge
  6.    local plr = "none"
  7.    for i = 1, #plrs do
  8.        v = plrs[i]
  9.        if v ~= safe.Players.LocalPlayer then
  10.            if v.Character then
  11.                if v.TeamColor ~= safe.Players.LocalPlayer.TeamColor and teamcheck then
  12.                    local hpos = wtos(v.Character.Head.Position)
  13.                    local idist = distFromCenter(hpos.X, hpos.Y)
  14.                    if idist < dist and idist < _G.maxdistfromcross then
  15.                        dist = idist
  16.                        plr = v
  17.                    end
  18.                elseif not teamcheck then
  19.                    local hpos = wtos(v.Character.Head.Position)
  20.                    local idist = distFromCenter(hpos.X, hpos.Y)
  21.                    if idist < dist and idist < _G.maxdistfromcross then
  22.                        dist = idist
  23.                        plr = v
  24.                    end
  25.                end
  26.            end
  27.        end
  28.    end
  29.    return plr, dist
  30. end
  31.  
  32. local AimAt = function(x, y)
  33.    local vps = cam.ViewportSize
  34.    local vpsx = vps.X
  35.    local vpsy = vps.Y
  36.    local screencenterx = vpsx/2
  37.    local screencentery = vpsy/2
  38.    local aimspeed = 5
  39.    local aimatx
  40.    local aimaty
  41.  
  42.    if x ~= 0 then
  43.        if x > screencenterx then
  44.            aimatx = -(screencenterx - x)
  45.            aimatx = aimatx/aimspeed
  46.            if aimatx + screencenterx > screencenterx * 2 then
  47.                aimatx = 0
  48.            end
  49.        end
  50.        if x < screencenterx then
  51.            aimatx = x - screencenterx
  52.            aimatx = aimatx/aimspeed
  53.            if aimatx + screencenterx < 0 then
  54.                aimatx = 0
  55.            end
  56.        end
  57.    end
  58.  
  59.    if y ~= 0 then
  60.        if y > screencentery then
  61.            aimaty = -(screencentery - y)
  62.            aimaty = aimaty/aimspeed
  63.            if aimaty + screencentery > screencentery * 2 then
  64.                aimaty = 0
  65.            end
  66.        end
  67.        if y < screencentery then
  68.            aimaty = y - screencentery
  69.            aimaty = aimaty/aimspeed
  70.            if aimaty + screencentery < 0 then
  71.                aimaty = 0
  72.            end
  73.        end
  74.    end
  75.    return aimatx, aimaty
  76. end
  77.  
  78. local MouseTests = function()
  79.    local player = safe.Players.LocalPlayer
  80.    local mouse = player:GetMouse()
  81.    local screensizex = mouse.ViewSizeX
  82.    local screensizey = mouse.ViewSizeY
  83.    local midx = screensizex/2
  84.    local midy = screensizey/2
  85.    local mousex = mouse.X
  86.    local mousey = mouse.Y
  87.    local moveamountx = midx - mousex
  88.    local moveamounty = midy - mousey
  89.    movethemouse(moveamountx, moveamounty)
  90.    local camera = safe.Workspace.Camera
  91.    local newmousex = safe.Players.LocalPlayer:GetMouse().X
  92.    local newmousey = safe.Players.LocalPlayer:GetMouse().Y
  93.    local closestplayer = getclosestPlayer()
  94.    if player.Character.Humanoid.Health > 0 then
  95.        if closestplayer ~= "none" then
  96.            if inlos(closestplayer.Character.Head.Position, closestplayer.Character) and visiblecheck then
  97.                local closesthead = closestplayer.Character.Head
  98.                local p = camera:WorldToScreenPoint(closesthead.Position)
  99.                local xdistancetohead, ydistancetohead = AimAt(p.X + _G.xaimoffset, p.Y + 32)
  100.                movethemouse(xdistancetohead, ydistancetohead)
  101.                if autoshoot then
  102.                    movethemouse(xdistancetohead, ydistancetohead)
  103.                    wait(1)
  104.                    Input.LeftClick(MOUSE_DOWN)
  105.                    wait()
  106.                end
  107. elseif not visiblecheck then
  108. local closesthead = closestplayer.Character.Head
  109.                local p = camera:WorldToScreenPoint(closesthead.Position)
  110.                local xdistancetohead, ydistancetohead = AimAt(p.X + _G.xaimoffset, p.Y + 32)
  111.                movethemouse(xdistancetohead, ydistancetohead)
  112.            end
  113.        end
  114.    end
  115. end
  116.  
  117. game:GetService('RunService').Stepped:connect(function()
  118.    if aimbotting then
  119.    --MouseTests()
  120.    end
  121. end)
  122.  
  123.  
  124. local plr = safe.Players.LocalPlayer
  125. local mouse = plr:GetMouse()
  126. print("Aimbot Loaded!")
  127.  
  128. MB2Held = false
  129.  
  130. function onKeyPress(inputObject,gameProcessed)
  131.    if inputObject.UserInputType == Enum.UserInputType.MouseButton2 then
  132.        MB2Held = true
  133.        while MB2Held do
  134.            if aimbotting then
  135.                MouseTests()
  136.            end
  137.            wait()
  138.        end
  139.    end
  140. end
  141.  
  142. function onKeyRelease(inputObject,gameProcessed)
  143.    if inputObject.UserInputType == Enum.UserInputType.MouseButton2 then
  144.        MB2Held = false
  145.    end
  146. end
  147.  
  148. game:GetService("UserInputService").InputBegan:connect(onKeyPress)
  149. game:GetService("UserInputService").InputEnded:connect(onKeyRelease)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top