Aimbot

 avatar
unknown
lua
a year ago
3.5 kB
9
Indexable
-- Customizable Aimbot Script

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")
local UserInputService = game:GetService("UserInputService")

local player = Players.LocalPlayer
local mouse = player:GetMouse()
local camera = Workspace.CurrentCamera

-- Customizable settings
local aimbotSettings = {
    FOV = 100, -- Field of view for targeting
    Smoothing = 0.1, -- Smoothing factor (0 to 1)
    Strength = 0.5, -- Strength of the aimbot (0 to 1)
    Range = 1000, -- Maximum range for targeting
}

-- Customizable keybinds
local keybinds = {
    ToggleAimbot = Enum.KeyCode.F, -- Key to toggle aimbot on/off
    ActivateAimbot = Enum.KeyCode.MouseButton2, -- Key to activate aimbot when enabled (e.g., right mouse button)
}

-- Aimbot state
local aimbotEnabled = false

-- Function to get the closest target within the FOV and range
local function getClosestTarget()
    local closestTarget = nil
    local shortestDistance = aimbotSettings.FOV
    local mousePosition = Vector2.new(mouse.X, mouse.Y)

    for _, potentialTarget in ipairs(Players:GetPlayers()) do
        if potentialTarget ~= player and potentialTarget.Character and potentialTarget.Character:FindFirstChild("HumanoidRootPart") then
            local targetPosition = potentialTarget.Character.HumanoidRootPart.Position
            local screenPosition, onScreen = camera:WorldToScreenPoint(targetPosition)
            local distance = (mouse.Hit.Position - targetPosition).magnitude

            if onScreen and distance <= aimbotSettings.Range then
                local targetScreenPosition = Vector2.new(screenPosition.X, screenPosition.Y)
                local screenDistance = (targetScreenPosition - mousePosition).magnitude

                if screenDistance < shortestDistance then
                    shortestDistance = screenDistance
                    closestTarget = potentialTarget
                end
            end
        end
    end

    return closestTarget
end

-- Function to smoothly aim at the target
local function smoothAim(targetPosition)
    local currentCameraCFrame = camera.CFrame
    local targetCFrame = CFrame.new(targetPosition)
    local newCFrame = currentCameraCFrame:Lerp(targetCFrame, aimbotSettings.Smoothing)
    mouse.Hit = newCFrame
end

-- Main aimbot function
local function aimbot()
    if aimbotEnabled then
        local target = getClosestTarget()
        if target and target.Character and target.Character:FindFirstChild("HumanoidRootPart") then
            local targetPosition = target.Character.HumanoidRootPart.Position
            -- Adjust aim based on strength setting
            local adjustedPosition = camera.CFrame.Position:Lerp(targetPosition, aimbotSettings.Strength)
            smoothAim(adjustedPosition)
        end
    end
end

-- Handle key inputs for toggling aimbot and activating features
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if not gameProcessed then
        if input.KeyCode == keybinds.ToggleAimbot then
            aimbotEnabled = not aimbotEnabled
            print("Aimbot " .. (aimbotEnabled and "Enabled" or "Disabled"))
        elseif input.KeyCode == keybinds.ActivateAimbot then
            if aimbotEnabled then
                aimbot()
            end
        end
    end
end)

-- Connect the aimbot function to the RenderStepped event
RunService.RenderStepped:Connect(aimbot)
Editor is loading...
Leave a Comment