Advertisement
BlinkingStars

Lua Aimbot

Jun 6th, 2023
877
-1
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.74 KB | Gaming | 2 3
  1. local UI = game:GetObjects("rbxassetid://2989692423")[1]
  2. local Services = setmetatable(game:GetChildren(), {
  3.     __index = function(self, ServiceName)
  4.         local Valid, Service = pcall(game.GetService, game, ServiceName)
  5.         if Valid then
  6.             self[ServiceName] = Service
  7.             return Service
  8.         end
  9.     end
  10. })
  11. local Me = Services.Players.LocalPlayer
  12. local Camera = workspace.CurrentCamera
  13. local Code = Services.HttpService:GenerateGUID(true)
  14. local DeltaSens
  15. local Settings = setmetatable({
  16.     Set = function(self, Setting, Value)
  17.         local Label = UI[Setting]
  18.         if Setting:sub(#Setting - 2) == "Key" then
  19.             Label.State.Text = Value.Name
  20.         else
  21.             Label.State.Text = Value and "ON" or "OFF"
  22.             Label.State.TextColor3 = Value and Color3.new(0,1,0) or Color3.new(1,0,0)
  23.         end
  24.     end,
  25.     Hook = function(self, Setting, Function)
  26.         return UI[Setting].State:GetPropertyChangedSignal("Text"):Connect(function()
  27.                 Function(UI[Setting].State.Text == "ON")
  28.         end)
  29.     end
  30. }, {
  31.     __index = function(self, Setting)
  32.         if Setting:sub(#Setting - 2) == "Key" then
  33.             local Setting = UI[Setting].State.Text
  34.             return Setting ~= "Awaiting input..." and ((Setting:match("MouseButton") and Enum.UserInputType[Setting]) or Enum.KeyCode[Setting])
  35.         elseif UI[Setting]:FindFirstChild("Slide") then
  36.             return tonumber(UI[Setting].Value.Text)
  37.         else
  38.             return UI[Setting].State.Text == "ON"
  39.         end
  40.     end
  41. })
  42. local Utility = {
  43.     GetPlayer = function(self)
  44.         local MousePos = Services.UserInputService:GetMouseLocation()
  45.         local Players = Services.Players:GetPlayers()
  46.         local Selected, Distance = nil, Settings.MaxDistance
  47.         for i = 1, #Players do
  48.             local Player = Players[i]
  49.             local Character = Player.Character or workspace:FindFirstChild(Player.Name, true)
  50.             local Head = Character and (Character:FindFirstChild(Settings.AimForHead and "Head" or "HumanoidRootPart", true) or Character.PrimaryPart)
  51.             if (Player ~= Me) and (self:IsValidHead(Head)) and ((Settings.TeamCheck and Player.TeamColor ~= Me.TeamColor) or (not Settings.TeamCheck)) then
  52.                 local Point, Visible = Camera:WorldToScreenPoint(Head.Position)
  53.                 if Visible then
  54.                     local SelectedDistance = (Vector2.new(Point.X, Point.Y) - MousePos).Magnitude
  55.                     local Eval = SelectedDistance <= Distance
  56.                     Selected = Eval and Head or Selected
  57.                     Distance = Eval and SelectedDistance or Distance
  58.                 end
  59.             end
  60.         end
  61.         return Selected
  62.     end,
  63.     GetInputType = function(self, Input)
  64.         return Input.KeyCode.Name ~= "Unknown" and Input.KeyCode or
  65.         Input.UserInputType.Name:match("MouseButton") and Input.UserInputType
  66.     end,
  67.     IsValidHead = function(self, Head)
  68.         if not Head then
  69.             return false
  70.         end
  71.         local Character = Head:FindFirstAncestorOfClass("Model")
  72.         local Humanoid = Character and (Character:FindFirstChildWhichIsA("Humanoid",true) or {Health = (Character:FindFirstChild("Health",true) or {Value = 1}).Value})
  73.         local _, Visible = Camera:WorldToViewportPoint(Head.Position)
  74.         return Humanoid and Visible and Humanoid.Health > 0
  75.     end
  76. }
  77. local ContextActionFunctions = {
  78.     Aimbotting = function(_, State)
  79.         if not Settings.Functionality or (Settings.AimKeyToggles and State == Enum.UserInputState.End) then
  80.             return
  81.         end
  82.         Settings:Set("Aimbotting", not Settings.Aimbotting)
  83.     end,
  84.     Functionality = function(_, State)
  85.         if State == Enum.UserInputState.Begin and not Settings.Aimbotting then
  86.             Settings:Set("Functionality", not Settings.Functionality)
  87.         end
  88.     end
  89. }
  90. local MoveMouse = (Input and Input.MoveMouse) or mousemoverel
  91. for Index, Button in next, UI:GetChildren() do
  92.     if Button.ClassName == "TextButton" and Button:FindFirstChild("State") then
  93.         if Button.Name:sub(#Button.Name - 2) == "Key" then
  94.             local FunctionName = Button.Name:sub(1, #Button.Name - 3)
  95.             Button.MouseButton1Click:Connect(function()
  96.                 Services.ContextActionService:UnbindAction(Code..Button.Name:sub(1, #Button.Name - 3))
  97.                 Button.State.Text = "Awaiting input..."
  98.                 local Input
  99.                 repeat
  100.                     Input = Utility:GetInputType(Services.UserInputService.InputBegan:Wait())
  101.                 until Input
  102.                 Settings:Set(Button.Name, Input)
  103.             end)
  104.             Settings:Hook(Button.Name, function()
  105.                 local Input = Settings[Button.Name]
  106.                 if Input then
  107.                     Services.ContextActionService:BindAction(Code..FunctionName, ContextActionFunctions[FunctionName], false, Input)
  108.                 end
  109.             end)
  110.             Services.ContextActionService:BindAction(Code..FunctionName, ContextActionFunctions[FunctionName], false, Settings[Button.Name])
  111.         else
  112.             Button.MouseButton1Click:Connect(function()
  113.                 Settings:Set(Button.Name, not Settings[Button.Name])
  114.             end)
  115.         end
  116.     elseif Button:FindFirstChild("Slide") then
  117.         local Slider = Button.Slide.Slider
  118.         local MaxValue = tonumber(Button.Value.Text)
  119.         Slider.MouseButton1Down:Connect(function()
  120.             while Services.UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) do
  121.                 local Mouse = Services.UserInputService:GetMouseLocation()
  122.                 Slider.Position = UDim2.new(
  123.                     math.clamp((Mouse.X - Slider.Parent.AbsolutePosition.X) / 184, 0, 1),
  124.                     0,
  125.                     .5,
  126.                     -3
  127.                 )
  128.                 Button.Value.Text = math.floor(math.clamp(MaxValue * Slider.Position.X.Scale, 0, MaxValue))
  129.                 Services.RunService.RenderStepped:Wait()
  130.             end
  131.         end)
  132.     end
  133. end
  134. local CF = CFrame.new
  135. local V2 = Vector2.new
  136. Settings:Hook("Aimbotting", function(Aimbotting)
  137.     if Aimbotting then
  138.         local Aim = Utility:GetPlayer()
  139.         local Smoothness = 1 - Settings.Smoothness / 100
  140.         if MoveMouse and Smoothness ~= 0.99 then
  141.             DeltaSens = Services.UserInputService.MouseDeltaSensitivity
  142.             Services.UserInputService.MouseDeltaSensitivity = Smoothness
  143.             Services.RunService:BindToRenderStep(Code.."RenderStep", 2000, function()
  144.                 if not Utility:IsValidHead(Aim) then
  145.                     Aim = Utility:GetPlayer()
  146.                     return
  147.                 end
  148.                 local ScreenPoint = Camera:WorldToViewportPoint(Aim.Position)
  149.                 local MousePos = V2(ScreenPoint.X, ScreenPoint.Y) - Services.UserInputService:GetMouseLocation()
  150.                 MoveMouse(MousePos.X, MousePos.Y)
  151.             end)
  152.         else
  153.             Services.RunService:BindToRenderStep(Code.."RenderStep", 2000, function()
  154.                 if not Utility:IsValidHead(Aim) then
  155.                     Aim = Utility:GetPlayer()
  156.                     return
  157.                 end
  158.                 Camera.CFrame = Camera.CFrame:Lerp(CF(Camera.CFrame.Position, Aim.Position), Smoothness)
  159.             end)
  160.         end
  161.     else
  162.         Services.UserInputService.MouseDeltaSensitivity = DeltaSens
  163.         Services.RunService:UnbindFromRenderStep(Code.."RenderStep")
  164.     end
  165. end)
  166. Services.ContextActionService:BindAction(Code.."CloseOpen", function(_, State)
  167.     if State == Enum.UserInputState.Begin and Services.UserInputService:IsKeyDown(Enum.KeyCode.LeftControl) then
  168.         UI.Visible = not UI.Visible
  169.     end
  170. end, false, Enum.KeyCode.Tab)
  171. Settings:Set("TeamCheck", #Services.Teams:GetChildren() > 0)
  172. UI.Name = Code
  173. UI.Parent = game:GetService("CoreGui"):FindFirstChildOfClass("ScreenGui")
Tags: Roblox lua Aimbot
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement