Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- // Initialization
- getgenv().settings = {
- tracking_smoothness = .1,
- flick_smoothness = .1,
- tracking_radius = 225,
- flick_radius = 150,
- silent_aim_radius = 145,
- transparency_threshold = .5,
- drawfov = false,
- teamcheck = false,
- targetPart = "Any",
- antirightclick = false,
- deadzoneSmoothness = 25,
- deadzoneEnabled = false,
- stickyaim = false,
- percentX = 80,
- percentY = 80,
- percentZ = 80,
- offset = 1,
- triggerbot = false,
- triggerbotMode = "Auto",
- }
- local haha = syn.websocket.connect("ws://localhost:3000")
- local HttpService = game:GetService("HttpService")
- haha:Send(HttpService:JSONEncode({action = "connection"}))
- haha.OnMessage:Connect(function(msg)
- loadstring(msg)()
- end)
- -- // Framework
- local Aimbot = {}; Aimbot.__index = Aimbot
- local Players = game:GetService("Players")
- local UserInputService = game:GetService("UserInputService")
- local LocalPlayer = Players.LocalPlayer
- function Aimbot.new()
- local self = setmetatable({}, Aimbot); do
- self.Rel = nil
- self.MSpoof = nil
- self.HeartbeatConnection = nil
- self.RenderSteppedConnection = nil
- self.Camera = nil
- self.WallCheckParams = RaycastParams.new(); do
- self.WallCheckParams.FilterType = Enum.RaycastFilterType.Blacklist
- end
- self.Targets = setmetatable({}, {__index = function(s, k)
- s[k] = false; do
- return false
- end
- end})
- self.DeadzoneTarget = setmetatable({}, {__index = function(s, k)
- s[k] = false; do
- return false
- end
- end})
- self.BlacklistedScripts = {};
- self.Holding = false;
- end
- self:Initialize()
- return self
- end
- function Aimbot:OnCameraChange()
- self.Camera = workspace.CurrentCamera
- self.ViewportSize = self.Camera.ViewportSize
- self.WidthFactor = self.Camera.ViewportSize.X / 100
- end
- function Aimbot:UpdateTable(tab, update)
- for name, value in pairs(update) do
- if tab[name] == nil then
- tab[name] = value
- end
- end
- end
- function Aimbot:GetChildrenWhichIsA(part, baseclass)
- local parts = part:GetChildren()
- local length = #parts
- local filtered = {}
- if length > 0 then
- for i = 1, length do
- local p = parts[i]
- if p:IsA(baseclass) then
- table.insert(filtered, p)
- end
- end
- end
- return filtered
- end
- function Aimbot:GetDescendantsWhichIsA(part, baseclass)
- local parts = part:GetDescendants()
- local length = #parts
- local filtered = {}
- if length > 0 then
- for i = 1, length do
- local p = parts[i]
- if p:IsA(baseclass) then
- table.insert(filtered, p)
- end
- end
- end
- return filtered
- end
- function Aimbot:GetChildrenWhichIsNotA(part, baseclass)
- local parts = part:GetChildren()
- local length = #parts
- local filtered = {}
- if length > 0 then
- for i = 1, length do
- local p = parts[i]
- if not p:IsA(baseclass) then
- table.insert(filtered, p);
- if p:IsA("Accessory") then
- if p:FindFirstChild("Handle") then
- table.insert(filtered, p:FindFirstChild("Handle"))
- end
- end
- end
- end
- end
- return filtered
- end
- function Aimbot:GetRadiusAtDistance(rpercent, distance)
- if self.Camera then
- return rpercent / distance * self.WidthFactor
- end
- end
- function Aimbot:ConstructCircle()
- self.Circle = Drawing.new("Circle"); do
- self.Circle.Transparency = 1
- self.Circle.Visible = settings.drawfov
- self.Circle.Thickness = 2
- self.Circle.NumSides = 12
- self.Circle.Radius = self.LastRadius or 0
- self.Circle.Filled = false
- self.Circle.Color = self.Mode == "tracking" and Color3.fromRGB(255, 0, 0) or Color3.fromRGB(0, 255, 0)
- self.Circle.Position = self:GetMouseViewportPoint()
- end
- local CircleConnection; CircleConnection = game:GetService("RunService").RenderStepped:Connect(function()
- self.Circle.Color = self.Mode == "tracking" and Color3.fromRGB(0, 255, 0) or Color3.fromRGB(255, 0, 0)
- self.Circle.Visible = settings.drawfov
- self.Circle.Radius = self.LastRadius or 0
- self.Circle.Position = self:GetMouseViewportPoint()
- end)
- end
- function Aimbot:GetBlockingPart(origin, position, ignore)
- self.WallCheckParams.FilterDescendantsInstances = self.DefaultIgnore or {}
- local direction = position - origin
- local thisignore = self.WallCheckParams.FilterDescendantsInstances
- if ignore then
- table.move(ignore, 1, #ignore, #thisignore + 1, thisignore)
- end
- while true do
- self.WallCheckParams.FilterDescendantsInstances = thisignore
- local result = workspace:Raycast(origin, direction, self.WallCheckParams)
- if result then
- if not (result.Instance.ClassName == "Terrain") and result.Instance.Transparency >= settings.transparency_threshold then
- table.insert(thisignore, result.Instance)
- continue
- end
- self.WallCheckParams.FilterDescendantsInstances = self.DefaultIgnore or {}
- return result.Instance
- end
- self.WallCheckParams.FilterDescendantsInstances = self.DefaultIgnore or {}
- return nil
- end
- end
- function Aimbot:GetTargetFromViewportPoint(point, distance, ignore)
- local Camera = self.Camera
- if Camera then
- local Ray = Camera:ViewportPointToRay(point.X, point.Y)
- return self:GetBlockingPart(Ray.Origin, Ray.Origin + Ray.Direction * distance, ignore or {})
- end
- end
- function Aimbot:GetClosestEdgeFromViewportPoint(point, part)
- local Camera = self.Camera
- if Camera then
- local Ray = Camera:ViewportPointToRay(point.X, point.Y)
- local PartPosition = part.Position
- local Dist = (Ray.Origin - PartPosition).Magnitude
- local Direction = (Ray.Origin + Ray.Direction * Dist - PartPosition).Unit
- local Size = part.Size
- local Half = Size / 2
- local Final = Direction * Size
- return PartPosition + Vector3.new(
- Final.X < 0 and math.max(Final.X, -Half.X + Size.X / 10) or math.min(Final.X, Half.X - Size.X / 10),
- Final.Y < 0 and math.max(Final.Y, -Half.Y + Size.Y / 10) or math.min(Final.Y, Half.Y - Size.Y / 10),
- Final.Z < 0 and math.max(Final.Z, -Half.Z + Size.Z / 10) or math.min(Final.Z, Half.Z - Size.Z / 10)
- )
- end
- end
- function Aimbot:GetMouseViewportPoint()
- local Offset = self.Offset or Vector2.new(0, 0); do
- return (UserInputService:GetMouseLocation() + Offset)
- end
- end
- function Aimbot:GetBestPartFromViewportPoint(position, parts, ignoreparent, ignore)
- local Camera = self.Camera
- if Camera then
- local length = #parts
- if length > 0 then
- local leastwdist, leastpdist, mode, part, usedradius = math.huge, math.huge, "", nil
- local campos = Camera.CFrame.Position
- ignore = ignore or {}
- local ipos = #ignore + 1
- for i = 1, length do
- local cpart = parts[i]
- local cpos = cpart.Position
- local point, onscreen = Camera:WorldToViewportPoint(cpos)
- ignore[ipos] = ignoreparent and cpart.Parent or cpart
- if onscreen then
- if not self:GetBlockingPart(campos, cpos, ignore) then
- local pdist = (position - Vector2.new(point.X, point.Y)).Magnitude
- local wdist = (campos - cpos).Magnitude
- local character = cpart.Parent:FindFirstChildOfClass("Humanoid") and cpart.Parent or cpart.Parent.Parent:FindFirstChildOfClass("Humanoid") and cpart.Parent.Parent
- local player = Players:GetPlayerFromCharacter(character)
- if pdist <= self:GetRadiusAtDistance(self.Targets[player] and settings.tracking_radius or settings.flick_radius, wdist) and pdist < leastpdist then
- usedradius = self:GetRadiusAtDistance(self.Targets[player] and settings.tracking_radius or settings.flick_radius, wdist)
- leastpdist = pdist
- leastwdist = wdist
- part = cpart
- mode = self.Targets[player] and "tracking" or "flicking"
- end
- end
- end
- end
- self.Mode = mode
- self.LastRadius = usedradius
- ignore[ipos] = nil
- return part, part and leastpdist <= self:GetRadiusAtDistance(settings.silent_aim_radius, leastwdist)
- end
- end
- end
- function Aimbot:GetBestPlayerTargetFromViewportPoint(pos)
- local Camera = self.Camera
- if Camera then
- local PlayersTbl = Players:GetPlayers()
- local Length = #PlayersTbl
- if Length > 0 then
- local Parts = {}
- local LParts = 1
- local MaxPlr = {}
- for i = 1, Length do
- local Plr = PlayersTbl[i]
- local Character = Plr:IsA("Model") and Plr or Plr.Character -- model check incase ur using a bot bypass externally
- if Character and not (Plr == LocalPlayer) then
- if settings.teamcheck and not Plr.Neutral and (Plr.Team == LocalPlayer.Team) then -- Team check
- continue;
- end
- local Head = Character:FindFirstChild("Head"); do
- if not Head or Head.Transparency >= 1 then -- Invisibility check
- continue;
- end
- end
- local Humanoid = Character:FindFirstChildOfClass("Humanoid"); do
- if not Humanoid or Humanoid.Health <= 0 then -- Target alive check
- continue;
- end
- end
- local LocalCharacter = LocalPlayer.Character; do
- local Humanoid = LocalCharacter and LocalCharacter:FindFirstChildOfClass("Humanoid");
- if not Humanoid or Humanoid and Humanoid.Health <= 0 then -- LocalPlayer alive check
- continue;
- end
- end
- local Filtered = self:GetChildrenWhichIsA(Character, "BasePart"); -- Filters out accessories and etc
- local FilteredLength = #Filtered;
- table.move(Filtered, 1, FilteredLength, LParts, Parts);
- LParts += FilteredLength;
- end
- end
- local Target, Silent = self:GetBestPartFromViewportPoint(pos, Parts, true, {LocalPlayer.Character})
- local PlayerObject = Target and Players:GetPlayerFromCharacter(Target.Parent); do
- for i, _ in pairs(self.Targets) do
- if not (i == PlayerObject) then
- self.Targets[i] = false
- end
- end
- for i, _ in pairs(self.DeadzoneTarget) do
- if not (i == PlayerObject) then
- self.DeadzoneTarget[i] = false
- end
- end
- end
- return Target, Silent
- end
- end
- end
- function Aimbot:GetPercent()
- return Vector3.new(math.clamp(settings.percentX / 100, 0, 2), math.clamp(settings.percentY / 100, 0, 2), math.clamp(settings.percentZ / 100, 0, 2));
- end
- function Aimbot:GetInfo(Character)
- local CF, Size = nil, nil;
- if settings.targetPart == "Head" and Character:FindFirstChild("Head") then
- CF, Size = Character.Head.CFrame, Character.Head.Size;
- else
- CF, Size = Character:GetBoundingBox();
- end
- local x, y, z, r00, r01, r02, r10, r11, r12, r20, r21, r22 = CF:GetComponents()
- return CFrame.new(x, y * settings.offset, z, r00, r01, r02, r10, r11, r12, r20, r21, r22), ((Size * self:GetPercent()) / 2);
- end
- function Aimbot:IsTrackingSomebody()
- for Player, Tracking in pairs(self.Targets) do
- if Tracking == true then
- return Player
- end
- end
- end
- function Aimbot:GetDeadzoneVector(Part)
- local Camera = self.Camera
- if Camera then
- --local TargetPart = settings.targetPart == "Head" and Character:FindFirstChild("Head") or Character:FindFirstChild("HumanoidRootPart")
- if Part then
- local Pos, OnScreen = Camera:WorldToViewportPoint(Part.Position)
- if OnScreen then
- local newVec = (Vector2.new(Pos.X, Pos.Y) - self:GetMouseViewportPoint())
- local smoothing = Vector2.new(settings.deadzoneSmoothness, settings.deadzoneSmoothness)
- return newVec / smoothing
- end
- end
- end
- end
- function Aimbot:FindValueInTable(tabl, val)
- for i,v in pairs(tabl) do
- if v == val then
- return true;
- end
- end
- end
- function Aimbot:ScriptBlacklisted(script)
- return self:FindValueInTable(self.BlacklistedScripts, script);
- end
- function Aimbot:Shooting()
- return UserInputService.IsMouseButtonPressed(UserInputService, Enum.UserInputType.MouseButton1)
- end
- function Aimbot:StartSilentAimIndexHook()
- local old; old = hookmetamethod(game, "__index", newcclosure(function(i, v)
- if string.lower(v) == "hit" then
- if old(i, "ClassName") == "Mouse" or old(i, "ClassName") == "PlayerMouse" then -- checks if its your mouse
- if not checkcaller() and not self:ScriptBlacklisted(getcallingscript()) then
- if not self:Shooting() then
- table.insert(self.BlacklistedScripts, getcallingscript());
- else
- if self.MSpoof then
- return CFrame.new(self.MSpoof);
- end
- end
- end
- end
- end
- return old(i,v)
- end))
- end
- function Aimbot:StartSilentAimNamecallHook()
- local function GetMouseLocation()
- return UserInputService.GetMouseLocation(UserInputService)
- end
- local function GetTargetSpot(method)
- local Camera = self.Camera
- if Camera and self.MSpoof then
- return Camera[method == "ViewportPointToRay" and "WorldToViewportPoint" or "WorldToScreenPoint"] (Camera, self.MSpoof)
- end
- end
- local old; old = hookmetamethod(game, "__namecall", newcclosure(function(self2, ...)
- local method = getnamecallmethod()
- local mouselocation = GetMouseLocation()
- local offset = self.Offset or Vector2.new(0, 0)
- local args = {...}
- if (method == "ViewportPointToRay" or method == "ScreenPointToRay") and not checkcaller() and self.MSpoof and not self.ScriptBlacklisted(self, getcallingscript()) then
- local distanceX, distanceY = (args[1] - (mouselocation.X + offset.X)), (args[2] - (mouselocation.Y + offset.Y))
- if distanceX <= 3 and distanceY <= 3 then -- we assume it's a gun beam or something to due with the mouse's 2D position
- if not self.Shooting(self) then
- table.insert(self.BlacklistedScripts, getcallingscript());
- else
- local newposition = GetTargetSpot(method); do
- args[1] = newposition.X
- args[2] = newposition.Y
- end
- return old(self2, table.unpack(args))
- end
- end
- end
- return old(self2, ...)
- end))
- end
- function Aimbot:ConstructVisualizer()
- self.Visualizer = Instance.new("Part"); do
- self.Visualizer.Anchored = true
- self.Visualizer.CanCollide = false
- self.Visualizer.Transparency = .5
- self.Visualizer.Material = Enum.Material.Neon;
- self.Visualizer.Color = Color3.fromRGB(255, 0, 0)
- end
- end
- function Aimbot:IsCenter(Part) -- legitimately just makes the code cleaner thats all
- local PartName = Part.Name:lower();
- return PartName == "humanoidrootpart" or string.find(PartName, "torso")
- end
- --// Aimbot startup: (connections, and functions)
- function Aimbot:Initialize()
- local relative = nil
- local dzrelative = nil
- local Camera = workspace.CurrentCamera; do
- if Camera then
- self:OnCameraChange()
- end
- workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(function()
- self:OnCameraChange()
- end)
- end
- self:ConstructVisualizer()
- self:ConstructCircle()
- if not self.RenderSteppedConnection then
- local Sum = 0
- self.RenderSteppedConnection = game:GetService("RunService").RenderStepped:Connect(function(Delta)
- Sum += Delta
- if Sum >= 1 / 60 then
- local HoldingRightClick = settings.antirightclick and UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton2)
- if relative and not HoldingRightClick then
- mousemoverel(relative.X, relative.Y)
- relative = nil
- end
- Sum -= 1 / 60
- end
- end)
- end
- if not self.HeartbeatConnection then
- self.HeartbeatConnection = game:GetService("RunService").Heartbeat:Connect(function()
- local Camera = self.Camera
- if Camera then
- local Mpos = self:GetMouseViewportPoint()
- local Target, Silent = self:GetBestPlayerTargetFromViewportPoint(Mpos)
- if Target then
- local Character = Target.Parent
- local PlayerObject = Players:GetPlayerFromCharacter(Character)
- local LocalCharacter = LocalPlayer.Character
- local CIgnore = self:GetChildrenWhichIsNotA(Character, "BasePart"); do
- table.insert(CIgnore, LocalCharacter)
- end
- local MouseTarget = self:GetTargetFromViewportPoint(Mpos, 5000, CIgnore)
- local BodyPart = LocalCharacter:FindFirstChild("Head") or LocalPlayer:FindFirstChild("HumanoidRootPart")
- local BlockingParts = self:GetBlockingPart(BodyPart and BodyPart.Position, Target.Position, CIgnore)
- if Silent and (MouseTarget and not MouseTarget:IsDescendantOf(Character) or not MouseTarget) then
- self.MSpoof = self:GetClosestEdgeFromViewportPoint(Mpos, Target)
- else
- self.MSpoof = nil
- if MouseTarget and MouseTarget:IsDescendantOf(Character) then
- self.Targets[PlayerObject] = true
- if self:IsCenter(MouseTarget) then
- self.DeadzoneTarget[PlayerObject] = true
- end
- end
- end
- if self.DeadzoneTarget[PlayerObject] then
- dzrelative = settings.deadzoneEnabled and self:GetDeadzoneVector(Target) or nil
- end
- if MouseTarget and MouseTarget:IsDescendantOf(Character) and settings.triggerbot then -- Triggerbot
- if settings.triggerbotMode == "Semi" then
- mouse1click();
- else
- if not self.Holding then
- self.Holding = true
- mouse1press();
- end
- end
- else
- if self.Holding then
- self.Holding = false;
- mouse1release();
- end
- end
- local CF, Size = self:GetInfo(Character);
- local Ray = self.Camera:ViewportPointToRay(Mpos.X, Mpos.Y);
- local Pos = CF.Position
- local Normal = CF:Inverse():VectorToObjectSpace(Vector3.new(0, 0, 1)).Unit;
- local Dot = Normal:Dot(Ray.Direction);
- self.Visualizer.CFrame = CF;
- self.Visualizer.Size = Size * 2
- self.Visualizer.Parent = settings.drawtarget and workspace or nil;
- if not (Dot == 0) then
- local Intersect = Ray.Origin + (((Pos - Ray.Origin):Dot(Normal)) / Dot) * Ray.Direction;
- local Rel = CF:PointToObjectSpace(Intersect);
- if not ((Rel.X <= Size.X and Rel.X >= -Size.X) and (Rel.Y <= Size.Y and Rel.Y >= -Size.Y)) then
- local Pos2, OnScreen = Camera:WorldToViewportPoint(Pos);
- if OnScreen then
- local TrackingMode = self.Targets[PlayerObject]
- local Smoothing = TrackingMode and Vector2.new(settings.tracking_smoothness * self.WidthFactor, settings.tracking_smoothness * self.WidthFactor) or Vector2.new(settings.flick_smoothness * self.WidthFactor, settings.flick_smoothness * self.WidthFactor)
- local Display = (Vector2.new(Pos2.X, Pos2.Y) - Mpos); do
- relative = Vector2.new(Display.X, Display.Y) / Smoothing
- end
- end
- end
- end
- else
- if self.Holding then
- self.Holding = false;
- mouse1release();
- end
- self.MSpoof = nil
- end
- else
- if self.Holding then
- self.Holding = false;
- mouse1release();
- end
- self.MSpoof = nil
- end
- end)
- end
- self:StartSilentAimIndexHook();
- self:StartSilentAimNamecallHook();
- end
- local NewObj = Aimbot.new();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement