imaRapguy

Untitled

Sep 13th, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.17 KB | None | 0 0
  1. -- Services
  2. local Players = game:GetService("Players")
  3. local Workspace = game:GetService("Workspace")
  4. local RunService = game:GetService("RunService")
  5. local Player = Players.LocalPlayer
  6. local Camera = Workspace.CurrentCamera
  7.  
  8. -- Aimbot toggle
  9. local aimbotEnabled = false -- Start with aimbot disabled
  10.  
  11. -- Create the GUI for the aimbot toggle
  12. local screenGui = Instance.new("ScreenGui")
  13. screenGui.Name = "AimbotToggle_GUI"
  14. screenGui.Parent = Player:WaitForChild("PlayerGui")
  15. screenGui.ResetOnSpawn = false -- Ensures the GUI doesn't disappear when the player respawns
  16.  
  17. -- Create Aimbot Toggle Button
  18. local aimbotToggleButton = Instance.new("TextButton")
  19. aimbotToggleButton.Size = UDim2.new(0, 120, 0, 50)
  20. aimbotToggleButton.Position = UDim2.new(0, 0, 0, 200)
  21. aimbotToggleButton.Text = "Aimbot: OFF"
  22. aimbotToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
  23. aimbotToggleButton.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  24. aimbotToggleButton.Font = Enum.Font.SourceSans
  25. aimbotToggleButton.TextSize = 18
  26. aimbotToggleButton.Parent = screenGui
  27.  
  28. -- Dragging function for mobile and PC
  29. local dragging = false
  30. local dragStart, startPos
  31.  
  32. local function onDrag(input, gameProcessedEvent)
  33. if not gameProcessedEvent and dragging then
  34. local mousePos = input.Position
  35. local framePos = UDim2.new(0, mousePos.X - (aimbotToggleButton.AbsoluteSize.X / 2), 0, mousePos.Y - (aimbotToggleButton.AbsoluteSize.Y / 2))
  36. aimbotToggleButton.Position = UDim2.new(0, framePos.X.Offset, 0, framePos.Y.Offset)
  37. end
  38. end
  39.  
  40. aimbotToggleButton.InputBegan:Connect(function(input)
  41. if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
  42. dragging = true
  43. dragStart = input.Position
  44. startPos = aimbotToggleButton.Position
  45. input.Changed:Connect(function()
  46. if input.UserInputState == Enum.UserInputState.End then
  47. dragging = false
  48. end
  49. end)
  50. end
  51. end)
  52.  
  53. aimbotToggleButton.InputChanged:Connect(onDrag)
  54.  
  55. -- Function to log when aimbot is toggled
  56. local function toggleAimbot()
  57. aimbotEnabled = not aimbotEnabled
  58. if aimbotEnabled then
  59. aimbotToggleButton.Text = "Aimbot: ON"
  60. aimbotToggleButton.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  61. print("Aimbot Enabled")
  62. else
  63. aimbotToggleButton.Text = "Aimbot: OFF"
  64. aimbotToggleButton.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
  65. print("Aimbot Disabled")
  66. end
  67. end
  68.  
  69. -- Function to find the nearest player
  70. local function getNearestPlayer()
  71. local nearestPlayer = nil
  72. local shortestDistance = math.huge
  73.  
  74. for _, otherPlayer in pairs(Players:GetPlayers()) do
  75. if otherPlayer ~= Player and otherPlayer.Character and otherPlayer.Character:FindFirstChild("Head") then
  76. local head = otherPlayer.Character.Head
  77. local screenPoint, onScreen = Camera:WorldToViewportPoint(head.Position)
  78.  
  79. -- Only consider players whose heads are on screen
  80. if onScreen then
  81. local distance = (Camera.CFrame.Position - head.Position).Magnitude
  82. if distance < shortestDistance then
  83. shortestDistance = distance
  84. nearestPlayer = otherPlayer
  85. end
  86. end
  87. end
  88. end
  89.  
  90. return nearestPlayer
  91. end
  92.  
  93. -- Function to aim at the nearest player's head
  94. local function aimAtNearestPlayer()
  95. if aimbotEnabled then
  96. local nearestPlayer = getNearestPlayer()
  97.  
  98. if nearestPlayer and nearestPlayer.Character then
  99. local head = nearestPlayer.Character:FindFirstChild("Head")
  100. if head then
  101. -- Move the camera to aim at the nearest player's head
  102. Camera.CFrame = CFrame.new(Camera.CFrame.Position, head.Position)
  103. print("Aiming at player: " .. nearestPlayer.Name) -- Log the player being aimed at
  104. end
  105. end
  106. end
  107. end
  108.  
  109. -- Run the aim function every frame
  110. RunService.RenderStepped:Connect(function()
  111. aimAtNearestPlayer()
  112. end)
  113.  
  114. -- Button Connections
  115. aimbotToggleButton.MouseButton1Click:Connect(toggleAimbot)
Advertisement
Add Comment
Please, Sign In to add comment