Advertisement
tanrikuluaa137102

Aimbot

Jul 8th, 2024
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.86 KB | None | 0 0
  1. -- Services
  2. local Players = game:GetService("Players")
  3. local UserInputService = game:GetService("UserInputService")
  4. local RunService = game:GetService("RunService")
  5.  
  6. -- Variables
  7. local localPlayer = Players.LocalPlayer
  8. local camera = workspace.CurrentCamera
  9. local lockView = false
  10. local targetPlayer = nil
  11. local hotkey = Enum.KeyCode.L -- Default hotkey
  12.  
  13. -- Create ScreenGui
  14. local screenGui = Instance.new("ScreenGui", localPlayer:WaitForChild("PlayerGui"))
  15. screenGui.Name = "DestructiveAimbotGui"
  16.  
  17. -- Create TextLabel for Aimbot status
  18. local textLabel = Instance.new("TextLabel", screenGui)
  19. textLabel.Size = UDim2.new(0, 200, 0, 50)
  20. textLabel.Position = UDim2.new(0.5, -100, 0, 0)
  21. textLabel.Text = "Destructive Aimbot"
  22. textLabel.TextColor3 = Color3.new(1, 0, 0)
  23. textLabel.BackgroundTransparency = 1
  24. textLabel.Font = Enum.Font.SourceSansBold
  25. textLabel.TextSize = 24
  26.  
  27. -- Create TextLabel for Hotkey status
  28. local hotkeyLabel = Instance.new("TextLabel", screenGui)
  29. hotkeyLabel.Size = UDim2.new(0, 200, 0, 50)
  30. hotkeyLabel.Position = UDim2.new(0.5, -100, 0, 60)
  31. hotkeyLabel.Text = "Hotkey: L"
  32. hotkeyLabel.TextColor3 = Color3.new(1, 1, 1)
  33. hotkeyLabel.BackgroundTransparency = 1
  34. hotkeyLabel.Font = Enum.Font.SourceSans
  35. hotkeyLabel.TextSize = 18
  36.  
  37. -- Create TextBox for changing the hotkey
  38. local hotkeyBox = Instance.new("TextBox", screenGui)
  39. hotkeyBox.Size = UDim2.new(0, 200, 0, 50)
  40. hotkeyBox.Position = UDim2.new(0.5, -100, 0, 120)
  41. hotkeyBox.PlaceholderText = "Enter new hotkey..."
  42. hotkeyBox.Text = ""
  43. hotkeyBox.TextColor3 = Color3.new(1, 1, 1)
  44. hotkeyBox.BackgroundTransparency = 0.5
  45. hotkeyBox.BackgroundColor3 = Color3.new(0, 0, 0)
  46. hotkeyBox.Font = Enum.Font.SourceSans
  47. hotkeyBox.TextSize = 18
  48.  
  49. -- Function to find the closest player
  50. local function findClosestPlayer()
  51.     local closestPlayer = nil
  52.     local shortestDistance = math.huge -- Start with a very large number
  53.  
  54.     for _, player in pairs(Players:GetPlayers()) do
  55.         if player ~= localPlayer and player.Character and player.Character:FindFirstChild("Head") then
  56.             local distance = (localPlayer.Character.Head.Position - player.Character.Head.Position).magnitude
  57.             if distance < shortestDistance then
  58.                 closestPlayer = player
  59.                 shortestDistance = distance
  60.             end
  61.         end
  62.     end
  63.  
  64.     return closestPlayer
  65. end
  66.  
  67. -- Function to lock the camera onto the target player's head
  68. local function lockCamera(targetPlayer)
  69.     if targetPlayer and targetPlayer.Character and targetPlayer.Character:FindFirstChild("Head") then
  70.         local targetHead = targetPlayer.Character.Head
  71.         camera.CFrame = CFrame.new(camera.CFrame.Position, targetHead.Position)
  72.     end
  73. end
  74.  
  75. -- Function to handle input for toggling aimbot
  76. local function onInputBegan(input, gameProcessed)
  77.     if gameProcessed then return end
  78.     if input.KeyCode == hotkey then
  79.         lockView = not lockView
  80.         if lockView then
  81.             targetPlayer = findClosestPlayer()
  82.             textLabel.Text = "Destructive Aimbot: ON"
  83.         else
  84.             targetPlayer = nil
  85.             textLabel.Text = "Destructive Aimbot: OFF"
  86.         end
  87.     end
  88. end
  89.  
  90. -- Function to handle hotkey change input
  91. hotkeyBox.FocusLost:Connect(function(enterPressed)
  92.     if enterPressed then
  93.         local newHotkey = hotkeyBox.Text:upper()
  94.         hotkeyBox.Text = ""
  95.         if Enum.KeyCode[newHotkey] then
  96.             hotkey = Enum.KeyCode[newHotkey]
  97.             hotkeyLabel.Text = "Hotkey: " .. newHotkey
  98.         else
  99.             hotkeyLabel.Text = "Invalid Key. Try again."
  100.         end
  101.     end
  102. end)
  103.  
  104. -- Connect input event for toggling aimbot
  105. UserInputService.InputBegan:Connect(onInputBegan)
  106.  
  107. -- Update the camera every frame if lockView is true
  108. RunService.RenderStepped:Connect(function()
  109.     if lockView and targetPlayer then
  110.         lockCamera(targetPlayer)
  111.     end
  112. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement