Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Services
- local Players = game:GetService("Players")
- local Workspace = game:GetService("Workspace")
- local RunService = game:GetService("RunService")
- local Player = Players.LocalPlayer
- local Camera = Workspace.CurrentCamera
- -- Aimbot toggle
- local aimbotEnabled = false -- Start with aimbot disabled
- -- Create the GUI for the aimbot toggle
- local screenGui = Instance.new("ScreenGui")
- screenGui.Name = "AimbotToggle_GUI"
- screenGui.Parent = Player:WaitForChild("PlayerGui")
- screenGui.ResetOnSpawn = false -- Ensures the GUI doesn't disappear when the player respawns
- -- Create Aimbot Toggle Button
- local aimbotToggleButton = Instance.new("TextButton")
- aimbotToggleButton.Size = UDim2.new(0, 120, 0, 50)
- aimbotToggleButton.Position = UDim2.new(0, 0, 0, 200)
- aimbotToggleButton.Text = "Aimbot: OFF"
- aimbotToggleButton.TextColor3 = Color3.fromRGB(255, 255, 255)
- aimbotToggleButton.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- aimbotToggleButton.Font = Enum.Font.SourceSans
- aimbotToggleButton.TextSize = 18
- aimbotToggleButton.Parent = screenGui
- -- Dragging function for mobile and PC
- local dragging = false
- local dragStart, startPos
- local function onDrag(input, gameProcessedEvent)
- if not gameProcessedEvent and dragging then
- local mousePos = input.Position
- local framePos = UDim2.new(0, mousePos.X - (aimbotToggleButton.AbsoluteSize.X / 2), 0, mousePos.Y - (aimbotToggleButton.AbsoluteSize.Y / 2))
- aimbotToggleButton.Position = UDim2.new(0, framePos.X.Offset, 0, framePos.Y.Offset)
- end
- end
- aimbotToggleButton.InputBegan:Connect(function(input)
- if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
- dragging = true
- dragStart = input.Position
- startPos = aimbotToggleButton.Position
- input.Changed:Connect(function()
- if input.UserInputState == Enum.UserInputState.End then
- dragging = false
- end
- end)
- end
- end)
- aimbotToggleButton.InputChanged:Connect(onDrag)
- -- Function to log when aimbot is toggled
- local function toggleAimbot()
- aimbotEnabled = not aimbotEnabled
- if aimbotEnabled then
- aimbotToggleButton.Text = "Aimbot: ON"
- aimbotToggleButton.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- print("Aimbot Enabled")
- else
- aimbotToggleButton.Text = "Aimbot: OFF"
- aimbotToggleButton.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
- print("Aimbot Disabled")
- end
- end
- -- Function to find the nearest player
- local function getNearestPlayer()
- local nearestPlayer = nil
- local shortestDistance = math.huge
- for _, otherPlayer in pairs(Players:GetPlayers()) do
- if otherPlayer ~= Player and otherPlayer.Character and otherPlayer.Character:FindFirstChild("Head") then
- local head = otherPlayer.Character.Head
- local screenPoint, onScreen = Camera:WorldToViewportPoint(head.Position)
- -- Only consider players whose heads are on screen
- if onScreen then
- local distance = (Camera.CFrame.Position - head.Position).Magnitude
- if distance < shortestDistance then
- shortestDistance = distance
- nearestPlayer = otherPlayer
- end
- end
- end
- end
- return nearestPlayer
- end
- -- Function to aim at the nearest player's head
- local function aimAtNearestPlayer()
- if aimbotEnabled then
- local nearestPlayer = getNearestPlayer()
- if nearestPlayer and nearestPlayer.Character then
- local head = nearestPlayer.Character:FindFirstChild("Head")
- if head then
- -- Move the camera to aim at the nearest player's head
- Camera.CFrame = CFrame.new(Camera.CFrame.Position, head.Position)
- print("Aiming at player: " .. nearestPlayer.Name) -- Log the player being aimed at
- end
- end
- end
- end
- -- Run the aim function every frame
- RunService.RenderStepped:Connect(function()
- aimAtNearestPlayer()
- end)
- -- Button Connections
- aimbotToggleButton.MouseButton1Click:Connect(toggleAimbot)
Advertisement
Add Comment
Please, Sign In to add comment