Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local safe = setmetatable({}, {
- __index = function(_, k)
- return game:GetService(k)
- end
- })
- local movethemouse = mousemoverel --Mouse Move Function.
- local leftclickme = nil --Auto Shoot Key Press Thingy.
- local aimbotting = true -- Toggles.
- local autoshoot = false
- local teamcheck = false
- _G.xaimoffset = 0 --_G.xaimoffset = -25
- _G.maxdistfromcross = 179
- local cam = safe.Workspace.CurrentCamera -- Current Camera
- local lp = safe.Players.LocalPlayer -- Local Player
- local lpc = safe.Players.LocalPlayer.Character -- Local Player Character
- local wtos = function(v) -- World To Screen
- return cam:WorldToScreenPoint(v)
- end
- local distFromCenter = function(x, y)
- local vps = cam.ViewportSize -- Get ViewPortSize.
- local vpsx = vps.X
- local vpsy = vps.Y
- local screencenterx = vpsx/2
- local screencentery = vpsy/2
- local xdist = (x - screencenterx) -- X Distance From Mid Screen.
- local ydist = (y - screencentery) -- Y Distance From Mid Screen.
- local Hypotenuse = math.sqrt(math.pow(xdist, 2) + math.pow(ydist, 2))
- return Hypotenuse
- end
- local getclosestPlayer = function() -- Checks the closest player based on Hypotenuse.
- local plrs, v = safe.Players:GetPlayers()
- local maxdist = 75
- local dist = math.huge
- local plr = "none"
- for i = 1, #plrs do
- v = plrs[i]
- if v ~= safe.Players.LocalPlayer then
- if v.Character and v.Character:WaitForChild("Head",10) then
- if v.TeamColor ~= safe.Players.LocalPlayer.TeamColor and teamcheck then
- local hpos = wtos(v.Character.Head.Position)
- local idist = distFromCenter(hpos.X, hpos.Y)
- if idist < dist and idist < _G.maxdistfromcross then
- dist = idist
- plr = v
- end
- elseif not teamcheck then
- local hpos = wtos(v.Character.Head.Position)
- local idist = distFromCenter(hpos.X, hpos.Y)
- if idist < dist and idist < _G.maxdistfromcross then
- dist = idist
- plr = v
- end
- end
- end
- end
- end
- return plr, dist
- end
- local AimAt = function(x, y)
- local vps = cam.ViewportSize
- local vpsx = vps.X
- local vpsy = vps.Y
- local screencenterx = vpsx/2
- local screencentery = vpsy/2
- local aimspeed = 2
- local aimatx
- local aimaty
- if x ~= 0 then
- if x > screencenterx then
- aimatx = -(screencenterx - x)
- aimatx = aimatx/aimspeed
- if aimatx + screencenterx > screencenterx * 2 then
- aimatx = 0
- end
- end
- if x < screencenterx then
- aimatx = x - screencenterx
- aimatx = aimatx/aimspeed
- if aimatx + screencenterx < 0 then
- aimatx = 0
- end
- end
- end
- if y ~= 0 then
- if y > screencentery then
- aimaty = -(screencentery - y)
- aimaty = aimaty/aimspeed
- if aimaty + screencentery > screencentery * 2 then
- aimaty = 0
- end
- end
- if y < screencentery then
- aimaty = y - screencentery
- aimaty = aimaty/aimspeed
- if aimaty + screencentery < 0 then
- aimaty = 0
- end
- end
- end
- return aimatx, aimaty
- end
- local MouseTests = function()
- local player = safe.Players.LocalPlayer
- local mouse = player:GetMouse()
- local screensizex = mouse.ViewSizeX
- local screensizey = mouse.ViewSizeY
- local midx = screensizex/2
- local midy = screensizey/2
- local mousex = mouse.X
- local mousey = mouse.Y
- local moveamountx = midx - mousex
- local moveamounty = midy - mousey
- local camera = safe.Workspace.Camera
- local newmousex = safe.Players.LocalPlayer:GetMouse().X
- local newmousey = safe.Players.LocalPlayer:GetMouse().Y
- local closestplayer = getclosestPlayer()
- if player.Character.Humanoid.Health > 0 then
- if closestplayer ~= "none" then
- local closesthead = closestplayer.Character:WaitForChild("Head",10)
- if closesthead then
- local p = camera:WorldToScreenPoint(closesthead.Position)
- local xdistancetohead, ydistancetohead = AimAt(p.X + _G.xaimoffset, p.Y + 35)
- movethemouse(moveamountx + xdistancetohead, moveamounty + ydistancetohead)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement