aimbot and autoaim
Key Required

aimbot and autoaim

Gunfight ArenaFCoderFCoder 80K views 379 executesUpdated Aug 19, 2024
2.1/ 5(7 votes)
3443% Positive
Lua Script•151 lines (5336 chars)
-------------------made by FCODER--------------

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

local localPlayer = Players.LocalPlayer
local camera = Workspace.CurrentCamera

local AIM_KEY = Enum.KeyCode.B -- Key to toggle auto-aim
local AIMBOT_KEY = Enum.KeyCode.N -- Key to toggle aimbot mode
local AIM_RANGE = 100 -- Max distance to search for a target
local AIM_SPEED = 0.25 -- Speed at which the camera moves to the target (smooth for new players)
local aiming = false
local aimbotMode = false
local aimingConnection = nil
local lockedTarget = nil
local aimbotTarget = nil

-- Function to check if a player is in the camera's field of view
local function isPlayerInView(player)
    if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
        local headPosition = player.Character.Head.Position
        local directionToTarget = (headPosition - camera.CFrame.Position).Unit
        local cameraDirection = camera.CFrame.LookVector
        local angle = math.acos(cameraDirection:Dot(directionToTarget))

        -- Check if the target is within a 45-degree cone in front of the camera
        return angle < math.rad(45)
    end
    return false
end

-- Function to check if a player is alive
local function isPlayerAlive(player)
    return player.Character and player.Character:FindFirstChildOfClass("Humanoid") and player.Character.Humanoid.Health > 0
end

-- Function to find the closest target that is not on the same team, not dead, and in view
local function findClosestTarget()
    local closestTarget = nil
    local closestDistance = AIM_RANGE

    for _, player in pairs(Players:GetPlayers()) do
        if player ~= localPlayer and player.Team ~= localPlayer.Team and isPlayerAlive(player) and isPlayerInView(player) then
            local targetPosition = player.Character.HumanoidRootPart.Position
            local distance = (targetPosition - localPlayer.Character.HumanoidRootPart.Position).Magnitude

            if distance < closestDistance then
                closestDistance = distance
                closestTarget = player.Character.HumanoidRootPart
            end
        end
    end

    return closestTarget
end

-- Function to find the closest target's head that is not on the same team, not dead, and in view
local function findClosestHead()
    local closestHead = nil
    local closestDistance = AIM_RANGE

    for _, player in pairs(Players:GetPlayers()) do
        if player ~= localPlayer and player.Team ~= localPlayer.Team and isPlayerAlive(player) and isPlayerInView(player) then
            local headPosition = player.Character.Head.Position
            local distance = (headPosition - localPlayer.Character.HumanoidRootPart.Position).Magnitude

            if distance < closestDistance then
                closestDistance = distance
                closestHead = player.Character.Head
            end
        end
    end

    return closestHead
end

-- Function to smoothly aim at the target
local function aimAtTarget(target)
    if target then
        local targetPosition = target.Position
        local aimDirection = (targetPosition - camera.CFrame.Position).Unit

        -- Smoothly move the camera towards the target
        local newCameraCFrame = CFrame.new(camera.CFrame.Position, camera.CFrame.Position + aimDirection)
        camera.CFrame = camera.CFrame:Lerp(newCameraCFrame, AIM_SPEED)
    end
end

-- Function to continuously update the target
local function updateTarget()
    if aiming then
        local newTarget = findClosestTarget()
        if newTarget then
            lockedTarget = newTarget
        end
    elseif aimbotMode then
        local newHead = findClosestHead()
        if newHead then
            aimbotTarget = newHead
        end
    end
end

-- Toggle auto-aim on or off
UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if input.KeyCode == AIM_KEY and not gameProcessed then
        aiming = not aiming

        if aiming then
            updateTarget()
            aimingConnection = RunService.RenderStepped:Connect(function()
                if lockedTarget and isPlayerAlive(lockedTarget.Parent) then
                    aimAtTarget(lockedTarget)
                else
                    updateTarget()
                end
            end)
        else
            if aimingConnection then
                aimingConnection:Disconnect()
                aimingConnection = nil
                lockedTarget = nil
            end
        end
    end

    -- Toggle aimbot mode on or off
    if input.KeyCode == AIMBOT_KEY and not gameProcessed then
        aimbotMode = not aimbotMode

        if aimbotMode then
            updateTarget()
            aimingConnection = RunService.RenderStepped:Connect(function()
                if aimbotTarget and isPlayerAlive(aimbotTarget.Parent) then
                    aimAtTarget(aimbotTarget)
                else
                    updateTarget()
                end
            end)
        else
            if aimingConnection then
                aimingConnection:Disconnect()
                aimingConnection = nil
                aimbotTarget = nil
            end
        end
    end
end)

Features & Information

1_Join a Team: Ensure the local player is assigned to a team 2_Press "B": "Auto-Aim" Verify that the camera locks onto the nearest non-teammate player’s torso 3_Press "N": "Aimbot Mode"Verify that the camera locks onto the nearest non-teammate player’s head 4_Toggle Both Modes: Test toggling between modes to ensure each functions correctly --------------------how its works?-------------- press B again that will toggle to stop it same as aimbot too ---------------------------Smooth Transition--------------

Community Comments (15)

FCoderFCoderAug 19, 2024(edited)

yes script is made by me and its works on every games that are fps

FCoderFCoderAug 19, 2024(edited)

there will be bugs with this one i will update it so yeah

gzzzzzgzzzzzAug 19, 2024(edited)

doesnt work

HisakoHisakoAug 19, 2024(edited)

not working

UselessScripterUselessScripterAug 19, 2024(edited)

script is down because it made by "devhub" not him as he says failed * skidder!

FCoderFCoderAug 20, 2024(edited)

@UselessScripter i made this script do you have proof? cuz i do

FCoderFCoderAug 20, 2024(edited)

https://pastebin.com/npv5mEyQ

UselessScripterUselessScripterAug 20, 2024(edited)

@Vazy everyone here thinks u have ed or issues

UselessScripterUselessScripterAug 20, 2024(edited)

@FCoder are u dumb this source code is lit a copy of devhub source u just changed the credits :skull:

HekzmmmHekzmmmAug 22, 2024(edited)

@UselessScripter no wonder why your useless

UselessScripterUselessScripterAug 22, 2024(edited)

@Vazy bro is using my user againest me dumb child 10yo max fr

HekzmmmHekzmmmAug 22, 2024(edited)

@UselessScripter bro says you

FCoderFCoderAug 25, 2024(edited)

@UselessScripter well im not dumb thats true but did i ask??

El_EscarabajoEl_EscarabajoSep 8, 2024(edited)

“i make scripts using ai ” xd que descripcion mas good

AdamkjAdamkjJun 8, 2026

Doesn't work in Xeno

More Scripts for Gunfight Arena