```lua
--// Axiom Player Tools
--// Version: 1.62.13
--// Status: BETA 13
--// Player + ESP + Aimbot + Utilities + Developer
--// Rayfield Gen2
--// Keybind System: Toggle / Hold / Smart
--// Mouse Keys: LMB / RMB
--// Object Selector
--// Shared Target Database
--// No Silent Aim
--// No exthus.digital runtime requests

--========================================================--
-- SERVICES
--========================================================--

local Players = game:GetService("Players")
local Workspace = game:GetService("Workspace")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local TeleportService = game:GetService("TeleportService")
local Lighting = game:GetService("Lighting")
local VirtualUser = game:GetService("VirtualUser")
local HttpService = game:GetService("HttpService")
local Stats = game:GetService("Stats")
local CoreGui = game:GetService("CoreGui")

local LocalPlayer = Players.LocalPlayer
local Mouse = LocalPlayer:GetMouse()

--========================================================--
-- RAYFIELD GEN2
--========================================================--

local Rayfield = loadstring(game:HttpGet(
    "https://sirius.menu/gen2"
))()

local Window = Rayfield:CreateWindow({
    name = "Axiom Player Tools",
    subtitle = "BETA 13 • v1.62.13",
    sidebarLayout = true,
    theme = "default",
})

--========================================================--
-- STATE
--========================================================--

local PlayerState = {
    WalkSpeed = 16,
    JumpPower = 50,
    InfiniteJump = false,
    Gravity = 196.2,
    CameraFOV = 70,

    FlyEnabled = false,
    FlySpeed = 75,

    Noclip = false,
    AutoSprint = false,
    Fullbright = false,
    AntiAFK = false,
}

local ESP = {
    Enabled = false,
    NPCEnabled = false,

    Names = true,
    Distance = true,
    Health = true,
    Tracers = false,

    TeamColors = true,
    Rainbow = false,

    Outline = true,
    Fill = false,

    OutlineTransparency = 0,
    FillTransparency = 0.7,

    MaxDistance = 1000,

    PlayerColor = Color3.fromRGB(255, 255, 255),
    NPCColor = Color3.fromRGB(255, 170, 0),
}

local Aimbot = {
    Enabled = false,
    UseAimKey = true,

    AimAtPlayers = true,
    AimAtNPCs = false,

    OnlyVisible = true,
    TargetPart = "Head",
    LockTarget = false,

    TeamCheck = false,
    IgnoreDead = true,

    FOV = 150,
    MaxDistance = 500,
    Smoothness = 15,

    Prediction = false,
    PredictionStrength = 0.1,

    ShowFOV = false,
    FOVColor = Color3.fromRGB(255, 255, 255),

    Target = nil,
}

local Controls = {}

--========================================================--
-- HELPERS
--========================================================--

local function RegisterControl(name, control)
    Controls[name] = control
    return control
end

local function SetControlValue(control, value)
    if not control then
        return
    end

    pcall(function()
        if control.Set then
            control:Set(value, true)
        end
    end)
end

local function Copy(text)
    if type(setclipboard) == "function" then
        pcall(setclipboard, tostring(text))
    end
end

local function GetCamera()
    return Workspace.CurrentCamera
end

local function GetHumanoid(model)
    if not model then
        return nil
    end

    return model:FindFirstChildOfClass("Humanoid")
end

local function GetRoot(model)
    if not model then
        return nil
    end

    return model:FindFirstChild("HumanoidRootPart")
        or model:FindFirstChild("UpperTorso")
        or model:FindFirstChild("Torso")
end

local function GetTargetPart(model, name)
    if not model then
        return nil
    end

    return model:FindFirstChild(name)
        or model:FindFirstChild("Head")
        or GetRoot(model)
end

local function IsAlive(model)
    local humanoid = GetHumanoid(model)
    return humanoid and humanoid.Health > 0
end

--========================================================--
-- KEYBIND SYSTEM
--========================================================--

local KeybindSystem = {
    Bindings = {},

    MouseNames = {
        [Enum.UserInputType.MouseButton1] = "LMB",
        [Enum.UserInputType.MouseButton2] = "RMB",
        [Enum.UserInputType.MouseButton3] = "MMB",
    },
}

local function NormalizeKey(key)
    if typeof(key) == "EnumItem" then
        return key
    end

    if type(key) ~= "string" then
        return Enum.KeyCode.Unknown
    end

    local lower = key:lower()

    if lower == "lmb" then
        return Enum.UserInputType.MouseButton1
    elseif lower == "rmb" then
        return Enum.UserInputType.MouseButton2
    elseif lower == "mmb" then
        return Enum.UserInputType.MouseButton3
    end

    for _, item in ipairs(Enum.KeyCode:GetEnumItems()) do
        if item.Name:lower() == lower then
            return item
        end
    end

    return Enum.KeyCode.Unknown
end

local function KeyToString(key)
    if not key then
        return "Unknown"
    end

    if typeof(key) == "EnumItem" then
        if key.EnumType == Enum.UserInputType then
            return KeybindSystem.MouseNames[key] or key.Name
        end

        return key.Name
    end

    return tostring(key)
end

local function IsInputMatch(key, input)
    return key
        and input
        and (
            key == input.KeyCode
            or key == input.UserInputType
        )
end

function KeybindSystem:Register(name, key, mode)
    self.Bindings[name] = {
        Key = NormalizeKey(key),
        Mode = mode or "Toggle",
        Active = false,
        Held = false,
    }

    return self.Bindings[name]
end

function KeybindSystem:SetKey(name, key)
    local binding = self.Bindings[name]

    if not binding then
        return
    end

    binding.Key = NormalizeKey(key)
    binding.Held = false
    binding.Active = false
end

function KeybindSystem:SetMode(name, mode)
    local binding = self.Bindings[name]

    if not binding then
        return
    end

    if mode ~= "Toggle"
        and mode ~= "Hold"
        and mode ~= "Smart" then
        mode = "Toggle"
    end

    binding.Mode = mode
    binding.Held = false
    binding.Active = false
end

function KeybindSystem:IsActive(name)
    local binding = self.Bindings[name]
    return binding and binding.Active or false
end

function KeybindSystem:TriggerDown(name)
    local binding = self.Bindings[name]

    if not binding or binding.Held then
        return
    end

    binding.Held = true

    if binding.Mode == "Toggle" then
        binding.Active = not binding.Active

    elseif binding.Mode == "Hold" then
        binding.Active = true

    elseif binding.Mode == "Smart" then
        -- Smart = hold for mouse buttons, toggle for keyboard.
        if binding.Key.EnumType == Enum.UserInputType then
            binding.Active = true
        else
            binding.Active = not binding.Active
        end
    end
end

function KeybindSystem:TriggerUp(name)
    local binding = self.Bindings[name]

    if not binding then
        return
    end

    binding.Held = false

    if binding.Mode == "Hold" then
        binding.Active = false

    elseif binding.Mode == "Smart"
        and binding.Key.EnumType == Enum.UserInputType then
        binding.Active = false
    end
end

KeybindSystem:Register("Fly", Enum.KeyCode.F, "Toggle")
KeybindSystem:Register("Noclip", Enum.KeyCode.N, "Toggle")
KeybindSystem:Register("InfiniteJump", Enum.KeyCode.J, "Toggle")
KeybindSystem:Register("Fullbright", Enum.KeyCode.B, "Toggle")
KeybindSystem:Register("AntiAFK", Enum.KeyCode.P, "Toggle")
KeybindSystem:Register("AutoSprint", Enum.KeyCode.LeftShift, "Smart")
KeybindSystem:Register("Aimbot", Enum.UserInputType.MouseButton2, "Hold")

UserInputService.InputBegan:Connect(function(input, processed)
    if processed then
        return
    end

    for name, binding in pairs(KeybindSystem.Bindings) do
        if IsInputMatch(binding.Key, input) then
            KeybindSystem:TriggerDown(name)
        end
    end
end)

UserInputService.InputEnded:Connect(function(input)
    for name, binding in pairs(KeybindSystem.Bindings) do
        if IsInputMatch(binding.Key, input) then
            KeybindSystem:TriggerUp(name)
        end
    end
end)

--========================================================--
-- CHARACTER
--========================================================--

local Character
local Humanoid
local RootPart

local function UpdateCharacter(char)
    Character = char
    Humanoid = char and GetHumanoid(char)
    RootPart = char and GetRoot(char)
end

UpdateCharacter(LocalPlayer.Character)

local function ApplyMovement()
    if not Humanoid then
        return
    end

    Humanoid.WalkSpeed = PlayerState.WalkSpeed
    Humanoid.UseJumpPower = true
    Humanoid.JumpPower = PlayerState.JumpPower
end

local function ApplyGravity()
    Workspace.Gravity = PlayerState.Gravity
end

local function ApplyCameraFOV()
    local camera = GetCamera()

    if camera then
        camera.FieldOfView = PlayerState.CameraFOV
    end
end

local function ApplyFullbright()
    if not PlayerState.Fullbright then
        return
    end

    Lighting.Brightness = 2
    Lighting.ClockTime = 14
    Lighting.FogEnd = 100000
    Lighting.GlobalShadows = false
    Lighting.OutdoorAmbient = Color3.fromRGB(128, 128, 128)
end

local function UpdateNoclip()
    if not Character then
        return
    end

    for _, object in ipairs(Character:GetDescendants()) do
        if object:IsA("BasePart") then
            object.CanCollide = not PlayerState.Noclip
        end
    end
end

--========================================================--
-- FLY
--========================================================--

local FlyVelocity
local FlyGyro

local function CleanupFly()
    if FlyVelocity then
        FlyVelocity:Destroy()
        FlyVelocity = nil
    end

    if FlyGyro then
        FlyGyro:Destroy()
        FlyGyro = nil
    end
end

local function StartFly()
    if not PlayerState.FlyEnabled
        or not Character
        or not RootPart then
        return
    end

    CleanupFly()

    FlyVelocity = Instance.new("BodyVelocity")
    FlyVelocity.Name = "AxiomFlyVelocity"
    FlyVelocity.MaxForce = Vector3.new(
        math.huge,
        math.huge,
        math.huge
    )
    FlyVelocity.Velocity = Vector3.zero
    FlyVelocity.Parent = RootPart

    FlyGyro = Instance.new("BodyGyro")
    FlyGyro.Name = "AxiomFlyGyro"
    FlyGyro.MaxTorque = Vector3.new(
        math.huge,
        math.huge,
        math.huge
    )
    FlyGyro.P = 90000
    FlyGyro.Parent = RootPart
end

local function UpdateFly()
    if not PlayerState.FlyEnabled then
        return
    end

    if not RootPart or not Humanoid then
        StartFly()
        return
    end

    if not FlyVelocity or not FlyGyro then
        StartFly()
        return
    end

    local camera = GetCamera()

    if not camera then
        return
    end

    local move = Vector3.zero

    if UserInputService:IsKeyDown(Enum.KeyCode.W) then
        move += camera.CFrame.LookVector
    end

    if UserInputService:IsKeyDown(Enum.KeyCode.S) then
        move -= camera.CFrame.LookVector
    end

    if UserInputService:IsKeyDown(Enum.KeyCode.A) then
        move -= camera.CFrame.RightVector
    end

    if UserInputService:IsKeyDown(Enum.KeyCode.D) then
        move += camera.CFrame.RightVector
    end

    if UserInputService:IsKeyDown(Enum.KeyCode.E) then
        move += Vector3.yAxis
    end

    if UserInputService:IsKeyDown(Enum.KeyCode.Q) then
        move -= Vector3.yAxis
    end

    if move.Magnitude > 0 then
        move = move.Unit * PlayerState.FlySpeed
    end

    FlyVelocity.Velocity = move
    FlyGyro.CFrame = camera.CFrame
end

LocalPlayer.CharacterRemoving:Connect(function()
    CleanupFly()
end)

LocalPlayer.CharacterAdded:Connect(function(char)
    task.wait(0.2)

    UpdateCharacter(char)

    ApplyMovement()
    ApplyGravity()
    ApplyCameraFOV()

    if PlayerState.Fullbright then
        ApplyFullbright()
    end

    if PlayerState.Noclip then
        UpdateNoclip()
    end

    if PlayerState.FlyEnabled then
        task.wait(0.1)
        StartFly()
    end
end)

UserInputService.JumpRequest:Connect(function()
    if PlayerState.InfiniteJump and Humanoid then
        Humanoid:ChangeState(
            Enum.HumanoidStateType.Jumping
        )
    end
end)

--========================================================--
-- SHARED TARGET DATABASE
--========================================================--

local AxiomTargetDatabase = {
    Players = {},
    NPCs = {},

    PlayerSet = {},
    NPCSet = {},

    Dirty = true,
    LastRebuild = 0,
    RebuildDelay = 0.35,
}

local function IsNPCModel(object)
    if not object:IsA("Model") then
        return false
    end

    local humanoid = GetHumanoid(object)
    local root = object:FindFirstChild("HumanoidRootPart")

    if not humanoid or not root then
        return false
    end

    for _, player in ipairs(Players:GetPlayers()) do
        if player.Character == object then
            return false
        end
    end

    return true
end

local function MarkTargetDatabaseDirty()
    AxiomTargetDatabase.Dirty = true
end

local function RebuildTargetDatabase(force)
    local now = os.clock()

    if not force then
        if not AxiomTargetDatabase.Dirty then
            return false
        end

        if now - AxiomTargetDatabase.LastRebuild
            < AxiomTargetDatabase.RebuildDelay then
            return false
        end
    end

    AxiomTargetDatabase.LastRebuild = now
    AxiomTargetDatabase.Dirty = false

    table.clear(AxiomTargetDatabase.Players)
    table.clear(AxiomTargetDatabase.NPCs)
    table.clear(AxiomTargetDatabase.PlayerSet)
    table.clear(AxiomTargetDatabase.NPCSet)

    for _, player in ipairs(Players:GetPlayers()) do
        if player ~= LocalPlayer and player.Character then
            local model = player.Character

            if GetHumanoid(model) and GetRoot(model) then
                table.insert(
                    AxiomTargetDatabase.Players,
                    {
                        Player = player,
                        Model = model,
                    }
                )

                AxiomTargetDatabase.PlayerSet[model] = true
            end
        end
    end

    for _, object in ipairs(Workspace:GetDescendants()) do
        if IsNPCModel(object) then
            table.insert(
                AxiomTargetDatabase.NPCs,
                {
                    Model = object,
                }
            )

            AxiomTargetDatabase.NPCSet[object] = true
        end
    end

    return true
end

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(MarkTargetDatabaseDirty)
    player.CharacterRemoving:Connect(MarkTargetDatabaseDirty)
    MarkTargetDatabaseDirty()
end)

Players.PlayerRemoving:Connect(MarkTargetDatabaseDirty)

for _, player in ipairs(Players:GetPlayers()) do
    player.CharacterAdded:Connect(MarkTargetDatabaseDirty)
    player.CharacterRemoving:Connect(MarkTargetDatabaseDirty)
end

Workspace.DescendantAdded:Connect(function(object)
    if object:IsA("Model")
        or object:IsA("Humanoid")
        or object:IsA("BasePart") then
        MarkTargetDatabaseDirty()
    end
end)

Workspace.DescendantRemoving:Connect(
    MarkTargetDatabaseDirty
)

RebuildTargetDatabase(true)

--========================================================--
-- ESP
--========================================================--

local ESPVisuals = {}
local ESPRefreshNeeded = true

local ESPGui

pcall(function()
    ESPGui = Instance.new("ScreenGui")
    ESPGui.Name = "AxiomESP"
    ESPGui.ResetOnSpawn = false
    ESPGui.IgnoreGuiInset = true
    ESPGui.Parent = CoreGui
end)

local function ClearESPVisuals()
    for model, visuals in pairs(ESPVisuals) do
        if visuals.Highlight then
            visuals.Highlight:Destroy()
        end

        if visuals.Billboard then
            visuals.Billboard:Destroy()
        end

        if visuals.Tracer then
            visuals.Tracer:Destroy()
        end

        ESPVisuals[model] = nil
    end
end

local function RequestESPRefresh()
    ESPRefreshNeeded = true
end

local function GetESPColor(entry, isNPC)
    if ESP.Rainbow then
        return Color3.fromHSV(
            (os.clock() * 0.15) % 1,
            1,
            1
        )
    end

    if not isNPC
        and ESP.TeamColors
        and entry.Player
        and entry.Player.Team then

        local teamColor = entry.Player.Team.TeamColor

        if teamColor then
            return teamColor.Color
        end
    end

    return isNPC
        and ESP.NPCColor
        or ESP.PlayerColor
end

local function CreateESPVisual(entry, isNPC)
    local model = entry.Model
    local root = GetRoot(model)

    if not model or not root then
        return
    end

    local color = GetESPColor(entry, isNPC)

    local visuals = {}

    -- Destroy-before-apply behavior:
    -- this function only runs after ClearESPVisuals().
    if ESP.Outline or ESP.Fill then
        local highlight = Instance.new("Highlight")
        highlight.Name = "AxiomESPHighlight"
        highlight.Adornee = model
        highlight.DepthMode =
            Enum.HighlightDepthMode.AlwaysOnTop

        highlight.OutlineTransparency =
            ESP.Outline
            and ESP.OutlineTransparency
            or 1

        highlight.FillTransparency =
            ESP.Fill
            and ESP.FillTransparency
            or 1

        highlight.OutlineColor = color
        highlight.FillColor = color

        highlight.Parent = Workspace
        visuals.Highlight = highlight
    end

    if ESP.Names
        or ESP.Distance
        or ESP.Health then

        local billboard = Instance.new("BillboardGui")
        billboard.Name = "AxiomESPInfo"
        billboard.Adornee = root
        billboard.Size = UDim2.fromOffset(220, 60)
        billboard.StudsOffset = Vector3.new(0, 3, 0)
        billboard.AlwaysOnTop = true
        billboard.Parent = ESPGui or CoreGui

        local label = Instance.new("TextLabel")
        label.BackgroundTransparency = 1
        label.Size = UDim2.fromScale(1, 1)
        label.TextColor3 = color
        label.TextStrokeTransparency = 0
        label.Font = Enum.Font.GothamBold
        label.TextSize = 13
        label.TextWrapped = true
        label.Parent = billboard

        visuals.Billboard = billboard
        visuals.Label = label
    end

    if ESP.Tracers and ESPGui then
        local tracer = Instance.new("Frame")
        tracer.Name = "AxiomTracer"
        tracer.AnchorPoint = Vector2.new(0.5, 0.5)
        tracer.BorderSizePixel = 0
        tracer.BackgroundColor3 = color
        tracer.Size = UDim2.fromOffset(2, 2)
        tracer.Parent = ESPGui

        visuals.Tracer = tracer
    end

    ESPVisuals[model] = visuals
end

local function RefreshESP()
    if not ESPRefreshNeeded then
        return
    end

    ESPRefreshNeeded = false

    -- Explicitly destroy all old highlights/visuals first.
    ClearESPVisuals()

    if not ESP.Enabled and not ESP.NPCEnabled then
        return
    end

    for _, entry in ipairs(AxiomTargetDatabase.Players) do
        if ESP.Enabled then
            CreateESPVisual(entry, false)
        end
    end

    for _, entry in ipairs(AxiomTargetDatabase.NPCs) do
        if ESP.NPCEnabled then
            CreateESPVisual(entry, true)
        end
    end
end

local function UpdateESP()
    local camera = GetCamera()

    if not camera then
        return
    end

    local cameraPosition = camera.CFrame.Position

    for model, visuals in pairs(ESPVisuals) do
        if not model
            or not model.Parent then

            if visuals.Highlight then
                visuals.Highlight:Destroy()
            end

            if visuals.Billboard then
                visuals.Billboard:Destroy()
            end

            if visuals.Tracer then
                visuals.Tracer:Destroy()
            end

            ESPVisuals[model] = nil
            continue
        end

        local root = GetRoot(model)
        local humanoid = GetHumanoid(model)

        if not root then
            continue
        end

        local distance =
            (root.Position - cameraPosition).Magnitude

        local alive =
            humanoid
            and humanoid.Health > 0

        local onScreen, screenPosition =
            camera:WorldToViewportPoint(root.Position)

        local visible =
            distance <= ESP.MaxDistance
            and alive
            and onScreen
            and screenPosition.Z > 0

        if visuals.Highlight then
            visuals.Highlight.Enabled = visible
        end

        if visuals.Billboard then
            visuals.Billboard.Enabled = visible
        end

        if visuals.Tracer then
            visuals.Tracer.Visible = visible
        end

        if not visible then
            continue
        end

        if visuals.Label then
            local parts = {}

            local player =
                Players:GetPlayerFromCharacter(model)

            if ESP.Names then
                table.insert(
                    parts,
                    player and player.DisplayName
                        or model.Name
                )
            end

            if ESP.Distance then
                table.insert(
                    parts,
                    string.format(
                        "%dm",
                        math.floor(distance)
                    )
                )
            end

            if ESP.Health and humanoid then
                table.insert(
                    parts,
                    string.format(
                        "%d HP",
                        math.floor(humanoid.Health)
                    )
                )
            end

            visuals.Label.Text =
                table.concat(parts, " • ")
        end

        if visuals.Tracer then
            local viewport =
                camera.ViewportSize

            local start =
                Vector2.new(
                    viewport.X / 2,
                    viewport.Y
                )

            local finish =
                Vector2.new(
                    screenPosition.X,
                    screenPosition.Y
                )

            local difference = finish - start

            visuals.Tracer.Position =
                UDim2.fromOffset(
                    (start.X + finish.X) / 2,
                    (start.Y + finish.Y) / 2
                )

            visuals.Tracer.Size =
                UDim2.fromOffset(
                    2,
                    difference.Magnitude
                )

            visuals.Tracer.Rotation =
                math.deg(
                    math.atan2(
                        difference.Y,
                        difference.X
                    )
                ) + 90
        end
    end
end

--========================================================--
-- AIMBOT
--========================================================--

local FOVGui
local FOVCircle

pcall(function()
    FOVGui = Instance.new("ScreenGui")
    FOVGui.Name = "AxiomAimbotFOV"
    FOVGui.ResetOnSpawn = false
    FOVGui.IgnoreGuiInset = true
    FOVGui.Parent = CoreGui

    FOVCircle = Instance.new("Frame")
    FOVCircle.Name = "FOV"
    FOVCircle.AnchorPoint = Vector2.new(0.5, 0.5)
    FOVCircle.BackgroundTransparency = 1
    FOVCircle.BorderSizePixel = 0
    FOVCircle.Parent = FOVGui

    local corner = Instance.new("UICorner")
    corner.CornerRadius = UDim.new(1, 0)
    corner.Parent = FOVCircle

    local stroke = Instance.new("UIStroke")
    stroke.Thickness = 1
    stroke.Parent = FOVCircle
end)

local function UpdateFOV()
    if not FOVCircle then
        return
    end

    local camera = GetCamera()

    if not camera then
        return
    end

    FOVCircle.Visible = Aimbot.ShowFOV

    FOVCircle.Size =
        UDim2.fromOffset(
            Aimbot.FOV * 2,
            Aimbot.FOV * 2
        )

    FOVCircle.Position =
        UDim2.fromOffset(
            camera.ViewportSize.X / 2,
            camera.ViewportSize.Y / 2
        )

    local stroke =
        FOVCircle:FindFirstChildOfClass("UIStroke")

    if stroke then
        stroke.Color = Aimbot.FOVColor
    end
end

local function IsSameTeam(player)
    if not player then
        return false
    end

    return LocalPlayer.Team
        and player.Team
        and LocalPlayer.Team == player.Team
end

local function IsVisible(targetPart, targetModel)
    local camera = GetCamera()

    if not camera or not targetPart then
        return false
    end

    local origin = camera.CFrame.Position
    local direction =
        targetPart.Position - origin

    local params = RaycastParams.new()
    params.FilterType =
        Enum.RaycastFilterType.Exclude

    params.FilterDescendantsInstances = {
        Character,
        targetModel,
    }

    params.IgnoreWater = true

    local result =
        Workspace:Raycast(
            origin,
            direction,
            params
        )

    return result == nil
end

local function GetBestAimbotTarget()
    local camera = GetCamera()

    if not camera then
        return nil
    end

    local center =
        Vector2.new(
            camera.ViewportSize.X / 2,
            camera.ViewportSize.Y / 2
        )

    local best
    local bestFOV = Aimbot.FOV

    local function CheckEntry(entry, isNPC)
        if isNPC then
            if not Aimbot.AimAtNPCs then
                return
            end
        else
            if not Aimbot.AimAtPlayers then
                return
            end

            if Aimbot.TeamCheck
                and IsSameTeam(entry.Player) then
                return
            end
        end

        local model = entry.Model
        local humanoid = GetHumanoid(model)

        if not model
            or not model.Parent
            or not humanoid then
            return
        end

        if Aimbot.IgnoreDead
            and humanoid.Health <= 0 then
            return
        end

        local part =
            GetTargetPart(
                model,
                Aimbot.TargetPart
            )

        if not part then
            return
        end

        local distance =
            (part.Position -
                camera.CFrame.Position).Magnitude

        if distance > Aimbot.MaxDistance then
            return
        end

        local screen, visible =
            camera:WorldToViewportPoint(
                part.Position
            )

        if not visible or screen.Z <= 0 then
            return
        end

        local screenPosition =
            Vector2.new(
                screen.X,
                screen.Y
            )

        local fovDistance =
            (screenPosition - center).Magnitude

        if fovDistance > bestFOV then
            return
        end

        if Aimbot.OnlyVisible
            and not IsVisible(part, model) then
            return
        end

        bestFOV = fovDistance

        best = {
            Model = model,
            Player = entry.Player,
            Part = part,
            IsNPC = isNPC,
        }
    end

    for _, entry in ipairs(AxiomTargetDatabase.Players) do
        CheckEntry(entry, false)
    end

    for _, entry in ipairs(AxiomTargetDatabase.NPCs) do
        CheckEntry(entry, true)
    end

    return best
end

local function AimAtTarget(target)
    if not target
        or not target.Part
        or not target.Part.Parent then
        return
    end

    local camera = GetCamera()

    if not camera then
        return
    end

    local position = target.Part.Position

    if Aimbot.Prediction then
        local root = GetRoot(target.Model)

        if root then
            position +=
                root.AssemblyLinearVelocity
                * Aimbot.PredictionStrength
        end
    end

    local desired =
        CFrame.lookAt(
            camera.CFrame.Position,
            position
        )

    local alpha =
        math.clamp(
            1 / math.max(Aimbot.Smoothness, 1),
            0.01,
            1
        )

    camera.CFrame =
        camera.CFrame:Lerp(
            desired,
            alpha
        )
end

--========================================================--
-- OBJECT SELECTOR
--========================================================--

local ObjectSelector = {
    Active = false,
    Hovered = nil,
    Highlight = nil,
    LastPath = "",
}

local function IsValidIdentifier(name)
    return name:match(
        "^[A-Za-z_][A-Za-z0-9_]*$"
    ) ~= nil
end

local function GetInstancePath(instance)
    if not instance then
        return ""
    end

    local chain = {}
    local current = instance

    while current and current ~= game do
        table.insert(chain, 1, current)
        current = current.Parent
    end

    if current ~= game then
        return instance:GetFullName()
    end

    local path = "game"

    for _, object in ipairs(chain) do
        if object.Parent == game then
            path =
                'game:GetService("'
                .. object.Name
                .. '")'

        elseif IsValidIdentifier(object.Name) then
            path =
                path
                .. "."
                .. object.Name

        else
            path =
                path
                .. "["
                .. string.format("%q", object.Name)
                .. "]"
        end
    end

    return path
end

local function GetHighlightAdornee(target)
    if not target then
        return nil
    end

    if target:IsA("BasePart")
        or target:IsA("Model") then
        return target
    end

    local model =
        target:FindFirstAncestorOfClass("Model")

    if model then
        return model
    end

    local part =
        target:FindFirstAncestorWhichIsA("BasePart")

    return part
end

local function DestroySelectorHighlight()
    if ObjectSelector.Highlight then
        ObjectSelector.Highlight:Destroy()
        ObjectSelector.Highlight = nil
    end
end

local function SetSelectorHover(target)
    if ObjectSelector.Hovered == target then
        return
    end

    DestroySelectorHighlight()

    ObjectSelector.Hovered = target

    local adornee =
        GetHighlightAdornee(target)

    if not adornee then
        return
    end

    local highlight = Instance.new("Highlight")
    highlight.Name = "AxiomObjectSelectorHighlight"
    highlight.Adornee = adornee
    highlight.DepthMode =
        Enum.HighlightDepthMode.AlwaysOnTop

    highlight.FillTransparency = 0.75
    highlight.OutlineTransparency = 0
    highlight.FillColor =
        Color3.fromRGB(255, 200, 50)
    highlight.OutlineColor =
        Color3.fromRGB(255, 255, 255)

    highlight.Parent = Workspace

    ObjectSelector.Highlight = highlight
end

local function StopObjectSelector()
    ObjectSelector.Active = false
    ObjectSelector.Hovered = nil
    DestroySelectorHighlight()
end

local function StartObjectSelector()
    StopObjectSelector()
    ObjectSelector.Active = true
end

local function SelectObject()
    if not ObjectSelector.Active then
        return
    end

    local target = Mouse.Target

    if not target then
        return
    end

    local path =
        GetInstancePath(target)

    ObjectSelector.LastPath = path

    if Controls.ObjectPath then
        Controls.ObjectPath:Set(
            path,
            true
        )
    end

    StopObjectSelector()
end

-- Selector hover/update.
RunService.RenderStepped:Connect(function()
    if not ObjectSelector.Active then
        return
    end

    local target = Mouse.Target

    if target then
        SetSelectorHover(target)
    else
        ObjectSelector.Hovered = nil
        DestroySelectorHighlight()
    end
end)

UserInputService.InputBegan:Connect(function(input, processed)
    if not ObjectSelector.Active then
        return
    end

    if input.KeyCode == Enum.KeyCode.Escape then
        StopObjectSelector()
        return
    end

    if input.UserInputType
        == Enum.UserInputType.MouseButton1 then

        SelectObject()
    end
end)

--========================================================--
-- CONFIG
--========================================================--

local CONFIG_FOLDER = "Axiom"
local CONFIG_FILE = CONFIG_FOLDER .. "/AxiomConfig.json"

local function CanUseFileSystem()
    return type(isfolder) == "function"
        and type(makefolder) == "function"
        and type(isfile) == "function"
        and type(readfile) == "function"
        and type(writefile) == "function"
end

local function ColorToTable(color)
    return {
        R = color.R,
        G = color.G,
        B = color.B,
    }
end

local function TableToColor(value, fallback)
    if type(value) ~= "table" then
        return fallback
    end

    return Color3.new(
        tonumber(value.R) or fallback.R,
        tonumber(value.G) or fallback.G,
        tonumber(value.B) or fallback.B
    )
end

local function BuildConfig()
    local bindings = {}

    for name, binding in pairs(
        KeybindSystem.Bindings
    ) do
        bindings[name] = {
            Key = KeyToString(binding.Key),
            Mode = binding.Mode,
        }
    end

    return {
        Version = "1.62.13",

        Player = {
            WalkSpeed = PlayerState.WalkSpeed,
            JumpPower = PlayerState.JumpPower,
            InfiniteJump = PlayerState.InfiniteJump,
            Gravity = PlayerState.Gravity,
            CameraFOV = PlayerState.CameraFOV,

            FlyEnabled = PlayerState.FlyEnabled,
            FlySpeed = PlayerState.FlySpeed,

            Noclip = PlayerState.Noclip,
            AutoSprint = PlayerState.AutoSprint,
            Fullbright = PlayerState.Fullbright,
            AntiAFK = PlayerState.AntiAFK,
        },

        ESP = {
            Enabled = ESP.Enabled,
            NPCEnabled = ESP.NPCEnabled,

            Names = ESP.Names,
            Distance = ESP.Distance,
            Health = ESP.Health,
            Tracers = ESP.Tracers,

            TeamColors = ESP.TeamColors,
            Rainbow = ESP.Rainbow,

            Outline = ESP.Outline,
            Fill = ESP.Fill,

            OutlineTransparency =
                ESP.OutlineTransparency,

            FillTransparency =
                ESP.FillTransparency,

            MaxDistance = ESP.MaxDistance,

            PlayerColor =
                ColorToTable(ESP.PlayerColor),

            NPCColor =
                ColorToTable(ESP.NPCColor),
        },

        Aimbot = {
            Enabled = Aimbot.Enabled,
            UseAimKey = Aimbot.UseAimKey,

            AimAtPlayers = Aimbot.AimAtPlayers,
            AimAtNPCs = Aimbot.AimAtNPCs,

            OnlyVisible = Aimbot.OnlyVisible,
            TargetPart = Aimbot.TargetPart,
            LockTarget = Aimbot.LockTarget,

            TeamCheck = Aimbot.TeamCheck,
            IgnoreDead = Aimbot.IgnoreDead,

            FOV = Aimbot.FOV,
            MaxDistance = Aimbot.MaxDistance,
            Smoothness = Aimbot.Smoothness,

            Prediction = Aimbot.Prediction,
            PredictionStrength =
                Aimbot.PredictionStrength,

            ShowFOV = Aimbot.ShowFOV,
            FOVColor =
                ColorToTable(Aimbot.FOVColor),
        },

        Keybinds = bindings,
    }
end

local function EncodeConfig(config)
    return HttpService:JSONEncode(config)
end

local function DecodeConfig(text)
    local success, result =
        pcall(
            HttpService.JSONDecode,
            HttpService,
            text
        )

    if success and type(result) == "table" then
        return result
    end

    return nil
end

local function ApplyConfig(config)
    if type(config) ~= "table" then
        return false
    end

    local p = config.Player

    if type(p) == "table" then
        PlayerState.WalkSpeed =
            tonumber(p.WalkSpeed)
            or PlayerState.WalkSpeed

        PlayerState.JumpPower =
            tonumber(p.JumpPower)
            or PlayerState.JumpPower

        PlayerState.InfiniteJump =
            p.InfiniteJump == true

        PlayerState.Gravity =
            tonumber(p.Gravity)
            or PlayerState.Gravity

        PlayerState.CameraFOV =
            tonumber(p.CameraFOV)
            or PlayerState.CameraFOV

        PlayerState.FlyEnabled =
            p.FlyEnabled == true

        PlayerState.FlySpeed =
            tonumber(p.FlySpeed)
            or PlayerState.FlySpeed

        PlayerState.Noclip =
            p.Noclip == true

        PlayerState.AutoSprint =
            p.AutoSprint == true

        PlayerState.Fullbright =
            p.Fullbright == true

        PlayerState.AntiAFK =
            p.AntiAFK == true
    end

    local e = config.ESP

    if type(e) == "table" then
        ESP.Enabled = e.Enabled == true
        ESP.NPCEnabled = e.NPCEnabled == true

        ESP.Names = e.Names ~= false
        ESP.Distance = e.Distance ~= false
        ESP.Health = e.Health ~= false
        ESP.Tracers = e.Tracers == true

        ESP.TeamColors = e.TeamColors ~= false
        ESP.Rainbow = e.Rainbow == true

        ESP.Outline = e.Outline ~= false
        ESP.Fill = e.Fill == true

        ESP.OutlineTransparency =
            tonumber(e.OutlineTransparency)
            or ESP.OutlineTransparency

        ESP.FillTransparency =
            tonumber(e.FillTransparency)
            or ESP.FillTransparency

        ESP.MaxDistance =
            tonumber(e.MaxDistance)
            or ESP.MaxDistance

        ESP.PlayerColor =
            TableToColor(
                e.PlayerColor,
                ESP.PlayerColor
            )

        ESP.NPCColor =
            TableToColor(
                e.NPCColor,
                ESP.NPCColor
            )
    end

    local a = config.Aimbot

    if type(a) == "table" then
        Aimbot.Enabled = a.Enabled == true
        Aimbot.UseAimKey = a.UseAimKey ~= false

        Aimbot.AimAtPlayers =
            a.AimAtPlayers ~= false

        Aimbot.AimAtNPCs =
            a.AimAtNPCs == true

        Aimbot.OnlyVisible =
            a.OnlyVisible ~= false

        if type(a.TargetPart) == "string" then
            Aimbot.TargetPart = a.TargetPart
        end

        Aimbot.LockTarget =
            a.LockTarget == true

        Aimbot.TeamCheck =
            a.TeamCheck == true

        Aimbot.IgnoreDead =
            a.IgnoreDead ~= false

        Aimbot.FOV =
            tonumber(a.FOV)
            or Aimbot.FOV

        Aimbot.MaxDistance =
            tonumber(a.MaxDistance)
            or Aimbot.MaxDistance

        Aimbot.Smoothness =
            tonumber(a.Smoothness)
            or Aimbot.Smoothness

        Aimbot.Prediction =
            a.Prediction == true

        Aimbot.PredictionStrength =
            tonumber(a.PredictionStrength)
            or Aimbot.PredictionStrength

        Aimbot.ShowFOV =
            a.ShowFOV == true

        Aimbot.FOVColor =
            TableToColor(
                a.FOVColor,
                Aimbot.FOVColor
            )
    end

    local bindings = config.Keybinds

    if type(bindings) == "table" then
        for name, data in pairs(bindings) do
            if KeybindSystem.Bindings[name]
                and type(data) == "table" then

                if data.Key then
                    KeybindSystem:SetKey(
                        name,
                        data.Key
                    )
                end

                if data.Mode then
                    KeybindSystem:SetMode(
                        name,
                        data.Mode
                    )
                end
            end
        end
    end

    ApplyMovement()
    ApplyGravity()
    ApplyCameraFOV()

    if PlayerState.Fullbright then
        ApplyFullbright()
    end

    if PlayerState.Noclip then
        UpdateNoclip()
    end

    CleanupFly()

    if PlayerState.FlyEnabled then
        StartFly()
    end

    RequestESPRefresh()
    UpdateFOV()

    for name, value in pairs({
        WalkSpeed = PlayerState.WalkSpeed,
        JumpPower = PlayerState.JumpPower,
        Gravity = PlayerState.Gravity,
        CameraFOV = PlayerState.CameraFOV,
        FlySpeed = PlayerState.FlySpeed,
        InfiniteJump = PlayerState.InfiniteJump,
        Noclip = PlayerState.Noclip,
        Fly = PlayerState.FlyEnabled,
        AutoSprint = PlayerState.AutoSprint,
        Fullbright = PlayerState.Fullbright,
        AntiAFK = PlayerState.AntiAFK,

        ESPEnabled = ESP.Enabled,
        NPCESP = ESP.NPCEnabled,
        ESPNames = ESP.Names,
        ESPDistance = ESP.Distance,
        ESPHealth = ESP.Health,
        ESPTracers = ESP.Tracers,
        TeamColors = ESP.TeamColors,
        Rainbow = ESP.Rainbow,
        ESPOutline = ESP.Outline,
        ESPFill = ESP.Fill,
        ESPMaxDistance = ESP.MaxDistance,

        AimbotEnabled = Aimbot.Enabled,
        AimbotPlayers = Aimbot.AimAtPlayers,
        AimbotNPCs = Aimbot.AimAtNPCs,
        AimbotVisible = Aimbot.OnlyVisible,
        AimbotLock = Aimbot.LockTarget,
        AimbotTeamCheck = Aimbot.TeamCheck,
        AimbotIgnoreDead = Aimbot.IgnoreDead,
        AimbotFOV = Aimbot.FOV,
        AimbotMaxDistance = Aimbot.MaxDistance,
        AimbotSmoothness = Aimbot.Smoothness,
        AimbotPrediction = Aimbot.Prediction,
        AimbotPredictionStrength =
            Aimbot.PredictionStrength,
        AimbotShowFOV = Aimbot.ShowFOV,
    }) do
        if Controls[name] then
            SetControlValue(
                Controls[name],
                value
            )
        end
    end

    if Controls.AimbotPart then
        SetControlValue(
            Controls.AimbotPart,
            Aimbot.TargetPart
        )
    end

    return true
end

local function SaveConfig()
    if not CanUseFileSystem() then
        return false
    end

    pcall(function()
        if not isfolder(CONFIG_FOLDER) then
            makefolder(CONFIG_FOLDER)
        end
    end)

    return pcall(function()
        writefile(
            CONFIG_FILE,
            EncodeConfig(BuildConfig())
        )
    end)
end

local function LoadConfig()
    if not CanUseFileSystem()
        or not isfile(CONFIG_FILE) then
        return false
    end

    local success, text =
        pcall(readfile, CONFIG_FILE)

    if not success then
        return false
    end

    local config =
        DecodeConfig(text)

    if not config then
        return false
    end

    return ApplyConfig(config)
end

--========================================================--
-- TABS
--========================================================--

local PlayerTab = Window:CreateTab({
    name = "Player",
})

local ESPTab = Window:CreateTab({
    name = "ESP",
})

local AimbotTab = Window:CreateTab({
    name = "Aimbot",
})

local UtilitiesTab = Window:CreateTab({
    name = "Utilities",
})

local DeveloperTab = Window:CreateTab({
    name = "Developer",
})

--========================================================--
-- PLAYER TAB
--========================================================--

RegisterControl(
    "WalkSpeed",
    PlayerTab:CreateSlider({
        name = "WalkSpeed",
        range = {16, 250},
        increment = 1,
        value = PlayerState.WalkSpeed,
        callback = function(value)
            PlayerState.WalkSpeed = value
            ApplyMovement()
        end,
    })
)

RegisterControl(
    "JumpPower",
    PlayerTab:CreateSlider({
        name = "JumpPower",
        range = {50, 250},
        increment = 1,
        value = PlayerState.JumpPower,
        callback = function(value)
            PlayerState.JumpPower = value
            ApplyMovement()
        end,
    })
)

RegisterControl(
    "InfiniteJump",
    PlayerTab:CreateToggle({
        name = "Infinite Jump",
        value = PlayerState.InfiniteJump,
        callback = function(value)
            PlayerState.InfiniteJump = value
            KeybindSystem.Bindings.InfiniteJump.Active =
                value
        end,
    })
)

RegisterControl(
    "Gravity",
    PlayerTab:CreateSlider({
        name = "Gravity",
        range = {0, 300},
        increment = 1,
        value = PlayerState.Gravity,
        callback = function(value)
            PlayerState.Gravity = value
            ApplyGravity()
        end,
    })
)

RegisterControl(
    "CameraFOV",
    PlayerTab:CreateSlider({
        name = "Camera FOV",
        range = {40, 120},
        increment = 1,
        value = PlayerState.CameraFOV,
        callback = function(value)
            PlayerState.CameraFOV = value
            ApplyCameraFOV()
        end,
    })
)

RegisterControl(
    "Fly",
    PlayerTab:CreateToggle({
        name = "Fly",
        value = PlayerState.FlyEnabled,
        callback = function(value)
            PlayerState.FlyEnabled = value

            KeybindSystem.Bindings.Fly.Active =
                value

            if value then
                StartFly()
            else
                CleanupFly()
            end
        end,
    })
)

RegisterControl(
    "FlySpeed",
    PlayerTab:CreateSlider({
        name = "Fly Speed",
        range = {10, 250},
        increment = 1,
        value = PlayerState.FlySpeed,
        callback = function(value)
            PlayerState.FlySpeed = value
        end,
    })
)

RegisterControl(
    "Noclip",
    PlayerTab:CreateToggle({
        name = "Noclip",
        value = PlayerState.Noclip,
        callback = function(value)
            PlayerState.Noclip = value
            KeybindSystem.Bindings.Noclip.Active =
                value
            UpdateNoclip()
        end,
    })
)

RegisterControl(
    "AutoSprint",
    PlayerTab:CreateToggle({
        name = "Auto Sprint",
        value = PlayerState.AutoSprint,
        callback = function(value)
            PlayerState.AutoSprint = value
        end,
    })
)

RegisterControl(
    "Fullbright",
    PlayerTab:CreateToggle({
        name = "Fullbright",
        value = PlayerState.Fullbright,
        callback = function(value)
            PlayerState.Fullbright = value
            KeybindSystem.Bindings.Fullbright.Active =
                value

            if value then
                ApplyFullbright()
            end
        end,
    })
)

RegisterControl(
    "AntiAFK",
    PlayerTab:CreateToggle({
        name = "Anti AFK",
        value = PlayerState.AntiAFK,
        callback = function(value)
            PlayerState.AntiAFK = value
            KeybindSystem.Bindings.AntiAFK.Active =
                value
        end,
    })
)

--========================================================--
-- ESP TAB
--========================================================--

RegisterControl(
    "ESPEnabled",
    ESPTab:CreateToggle({
        name = "Player ESP",
        value = ESP.Enabled,
        callback = function(value)
            ESP.Enabled = value
            RequestESPRefresh()
        end,
    })
)

RegisterControl(
    "NPCESP",
    ESPTab:CreateToggle({
        name = "NPC ESP",
        value = ESP.NPCEnabled,
        callback = function(value)
            ESP.NPCEnabled = value
            RequestESPRefresh()
        end,
    })
)

RegisterControl(
    "ESPNames",
    ESPTab:CreateToggle({
        name = "Names",
        value = ESP.Names,
        callback = function(value)
            ESP.Names = value
            RequestESPRefresh()
        end,
    })
)

RegisterControl(
    "ESPDistance",
    ESPTab:CreateToggle({
        name = "Distance",
        value = ESP.Distance,
        callback = function(value)
            ESP.Distance = value
            RequestESPRefresh()
        end,
    })
)

RegisterControl(
    "ESPHealth",
    ESPTab:CreateToggle({
        name = "Health",
        value = ESP.Health,
        callback = function(value)
            ESP.Health = value
            RequestESPRefresh()
        end,
    })
)

RegisterControl(
    "ESPTracers",
    ESPTab:CreateToggle({
        name = "Tracers",
        value = ESP.Tracers,
        callback = function(value)
            ESP.Tracers = value
            RequestESPRefresh()
        end,
    })
)

RegisterControl(
    "TeamColors",
    ESPTab:CreateToggle({
        name = "Team Colors",
        value = ESP.TeamColors,
        callback = function(value)
            ESP.TeamColors = value
            RequestESPRefresh()
        end,
    })
)

RegisterControl(
    "Rainbow",
    ESPTab:CreateToggle({
        name = "Rainbow",
        value = ESP.Rainbow,
        callback = function(value)
            ESP.Rainbow = value
            RequestESPRefresh()
        end,
    })
)

RegisterControl(
    "ESPOutline",
    ESPTab:CreateToggle({
        name = "Outline",
        value = ESP.Outline,
        callback = function(value)
            ESP.Outline = value
            RequestESPRefresh()
        end,
    })
)

RegisterControl(
    "ESPFill",
    ESPTab:CreateToggle({
        name = "Fill",
        value = ESP.Fill,
        callback = function(value)
            ESP.Fill = value
            RequestESPRefresh()
        end,
    })
)

ESPTab:CreateSlider({
    name = "Outline Transparency",
    range = {0, 1},
    increment = 0.05,
    value = ESP.OutlineTransparency,
    callback = function(value)
        ESP.OutlineTransparency = value
        RequestESPRefresh()
    end,
})

ESPTab:CreateSlider({
    name = "Fill Transparency",
    range = {0, 1},
    increment = 0.05,
    value = ESP.FillTransparency,
    callback = function(value)
        ESP.FillTransparency = value
        RequestESPRefresh()
    end,
})

RegisterControl(
    "ESPMaxDistance",
    ESPTab:CreateSlider({
        name = "Max Distance",
        range = {50, 5000},
        increment = 50,
        value = ESP.MaxDistance,
        suffix = " studs",
        callback = function(value)
            ESP.MaxDistance = value
        end,
    })
)

ESPTab:CreateColorPicker({
    name = "Player ESP Color",
    color = ESP.PlayerColor,
    callback = function(color)
        ESP.PlayerColor = color
        RequestESPRefresh()
    end,
})

ESPTab:CreateColorPicker({
    name = "NPC ESP Color",
    color = ESP.NPCColor,
    callback = function(color)
        ESP.NPCColor = color
        RequestESPRefresh()
    end,
})

--========================================================--
-- AIMBOT TAB
--========================================================--

RegisterControl(
    "AimbotEnabled",
    AimbotTab:CreateToggle({
        name = "Enabled",
        value = Aimbot.Enabled,
        callback = function(value)
            Aimbot.Enabled = value

            if not value then
                Aimbot.Target = nil
            end
        end,
    })
)

RegisterControl(
    "AimbotPlayers",
    AimbotTab:CreateToggle({
        name = "Aim at Players",
        value = Aimbot.AimAtPlayers,
        callback = function(value)
            Aimbot.AimAtPlayers = value
        end,
    })
)

RegisterControl(
    "AimbotNPCs",
    AimbotTab:CreateToggle({
        name = "Aim at NPCs",
        value = Aimbot.AimAtNPCs,
        callback = function(value)
            Aimbot.AimAtNPCs = value
        end,
    })
)

RegisterControl(
    "AimbotVisible",
    AimbotTab:CreateToggle({
        name = "Only Visible",
        value = Aimbot.OnlyVisible,
        callback = function(value)
            Aimbot.OnlyVisible = value
        end,
    })
)

RegisterControl(
    "AimbotLock",
    AimbotTab:CreateToggle({
        name = "Lock Target",
        value = Aimbot.LockTarget,
        callback = function(value)
            Aimbot.LockTarget = value

            if not value then
                Aimbot.Target = nil
            end
        end,
    })
)

RegisterControl(
    "AimbotTeamCheck",
    AimbotTab:CreateToggle({
        name = "Team Check",
        value = Aimbot.TeamCheck,
        callback = function(value)
            Aimbot.TeamCheck = value
        end,
    })
)

RegisterControl(
    "AimbotIgnoreDead",
    AimbotTab:CreateToggle({
        name = "Ignore Dead",
        value = Aimbot.IgnoreDead,
        callback = function(value)
            Aimbot.IgnoreDead = value
        end,
    })
)

RegisterControl(
    "AimbotPart",
    AimbotTab:CreateDropdown({
        name = "Target Part",
        options = {
            "Head",
            "HumanoidRootPart",
            "UpperTorso",
            "Torso",
        },
        value = Aimbot.TargetPart,
        callback = function(value)
            Aimbot.TargetPart = value
        end,
    })
)

RegisterControl(
    "AimbotFOV",
    AimbotTab:CreateSlider({
        name = "FOV",
        range = {10, 500},
        increment = 5,
        value = Aimbot.FOV,
        suffix = " px",
        callback = function(value)
            Aimbot.FOV = value
            UpdateFOV()
        end,
    })
)

RegisterControl(
    "AimbotMaxDistance",
    AimbotTab:CreateSlider({
        name = "Max Distance",
        range = {50, 3000},
        increment = 25,
        value = Aimbot.MaxDistance,
        suffix = " studs",
        callback = function(value)
            Aimbot.MaxDistance = value
        end,
    })
)

RegisterControl(
    "AimbotSmoothness",
    AimbotTab:CreateSlider({
        name = "Smoothness",
        range = {1, 100},
        increment = 1,
        value = Aimbot.Smoothness,
        callback = function(value)
            Aimbot.Smoothness = value
        end,
    })
)

RegisterControl(
    "AimbotPrediction",
    AimbotTab:CreateToggle({
        name = "Prediction",
        value = Aimbot.Prediction,
        callback = function(value)
            Aimbot.Prediction = value
        end,
    })
)

RegisterControl(
    "AimbotPredictionStrength",
    AimbotTab:CreateSlider({
        name = "Prediction Strength",
        range = {0, 1},
        increment = 0.01,
        value = Aimbot.PredictionStrength,
        callback = function(value)
            Aimbot.PredictionStrength = value
        end,
    })
)

RegisterControl(
    "AimbotShowFOV",
    AimbotTab:CreateToggle({
        name = "Show FOV",
        value = Aimbot.ShowFOV,
        callback = function(value)
            Aimbot.ShowFOV = value
            UpdateFOV()
        end,
    })
)

AimbotTab:CreateColorPicker({
    name = "FOV Color",
    color = Aimbot.FOVColor,
    callback = function(color)
        Aimbot.FOVColor = color
        UpdateFOV()
    end,
})

RegisterControl(
    "AimbotUseAimKey",
    AimbotTab:CreateToggle({
        name = "Use Aim Key",
        value = Aimbot.UseAimKey,
        callback = function(value)
            Aimbot.UseAimKey = value
        end,
    })
)

--========================================================--
-- UTILITIES TAB
--========================================================--

UtilitiesTab:CreateButton({
    name = "Rejoin Server",
    callback = function()
        TeleportService:TeleportToPlaceInstance(
            game.PlaceId,
            game.JobId,
            LocalPlayer
        )
    end,
})

UtilitiesTab:CreateButton({
    name = "Server Hop",
    callback = function()
        TeleportService:Teleport(game.PlaceId)
    end,
})

UtilitiesTab:CreateButton({
    name = "Reset Character",
    callback = function()
        if Humanoid then
            Humanoid.Health = 0
        end
    end,
})

UtilitiesTab:CreateButton({
    name = "Copy Job ID",
    callback = function()
        Copy(game.JobId)
    end,
})

UtilitiesTab:CreateButton({
    name = "Copy Place ID",
    callback = function()
        Copy(game.PlaceId)
    end,
})

UtilitiesTab:CreateButton({
    name = "Copy User ID",
    callback = function()
        Copy(LocalPlayer.UserId)
    end,
})

local StatsLabel

pcall(function()
    StatsLabel =
        UtilitiesTab:CreateLabel(
            "FPS: -- | Ping: -- | Players: --"
        )
end)

--========================================================--
-- DEVELOPER TAB
--========================================================--

DeveloperTab:CreateButton({
    name = "Copy Position",
    callback = function()
        if RootPart then
            Copy(
                string.format(
                    "%.3f, %.3f, %.3f",
                    RootPart.Position.X,
                    RootPart.Position.Y,
                    RootPart.Position.Z
                )
            )
        end
    end,
})

DeveloperTab:CreateButton({
    name = "Copy Velocity",
    callback = function()
        if RootPart then
            local velocity =
                RootPart.AssemblyLinearVelocity

            Copy(
                string.format(
                    "%.3f, %.3f, %.3f",
                    velocity.X,
                    velocity.Y,
                    velocity.Z
                )
            )
        end
    end,
})

DeveloperTab:CreateButton({
    name = "Copy User Info",
    callback = function()
        Copy(
            string.format(
                "Name: %s\nDisplay: %s\nUserId: %d\nAccountAge: %d",
                LocalPlayer.Name,
                LocalPlayer.DisplayName,
                LocalPlayer.UserId,
                LocalPlayer.AccountAge
            )
        )
    end,
})

DeveloperTab:CreateButton({
    name = "Inspect Character",
    callback = function()
        if not Character then
            return
        end

        local output = {}

        for _, object in ipairs(
            Character:GetDescendants()
        ) do
            table.insert(
                output,
                object:GetFullName()
            )
        end

        Copy(table.concat(output, "\n"))
    end,
})

DeveloperTab:CreateButton({
    name = "Inspect Humanoid",
    callback = function()
        if not Humanoid then
            return
        end

        local output = {}

        for property, value in pairs({
            Health = Humanoid.Health,
            MaxHealth = Humanoid.MaxHealth,
            WalkSpeed = Humanoid.WalkSpeed,
            JumpPower = Humanoid.JumpPower,
            HipHeight = Humanoid.HipHeight,
            RigType = tostring(Humanoid.RigType),
            State = tostring(
                Humanoid:GetState()
            ),
        }) do
            table.insert(
                output,
                property .. ": " .. tostring(value)
            )
        end

        Copy(table.concat(output, "\n"))
    end,
})

DeveloperTab:CreateDivider()

DeveloperTab:CreateButton({
    name = "Start Object Selector",
    description = "Hover an object, then click it to copy its path.",
    callback = function()
        StartObjectSelector()
    end,
})

RegisterControl(
    "ObjectPath",
    DeveloperTab:CreateInput({
        name = "Selected Object Path",
        value = "",
        placeholder = "game:GetService(\"Workspace\")....",
        callback = function(value)
            ObjectSelector.LastPath = value
        end,
    })
)

DeveloperTab:CreateButton({
    name = "Copy Selected Path",
    callback = function()
        if ObjectSelector.LastPath ~= "" then
            Copy(ObjectSelector.LastPath)
        end
    end,
})

DeveloperTab:CreateButton({
    name = "Clear Object Selector",
    callback = function()
        StopObjectSelector()

        if Controls.ObjectPath then
            Controls.ObjectPath:Set("", true)
        end

        ObjectSelector.LastPath = ""
    end,
})

--========================================================--
-- KEYBIND CONTROLS
--========================================================--

local function CreateKeybindControl(
    tab,
    name,
    bindingName
)
    local binding =
        KeybindSystem.Bindings[bindingName]

    if not binding then
        return
    end

    tab:CreateKeybind({
        name = name .. " Key",
        value = binding.Key,
        onChanged = function(key)
            KeybindSystem:SetKey(
                bindingName,
                key
            )
        end,
    })

    tab:CreateDropdown({
        name = name .. " Mode",
        options = {
            "Toggle",
            "Hold",
            "Smart",
        },
        value = binding.Mode,
        callback = function(mode)
            KeybindSystem:SetMode(
                bindingName,
                mode
            )
        end,
    })
end

DeveloperTab:CreateDivider()

CreateKeybindControl(
    DeveloperTab,
    "Fly",
    "Fly"
)

CreateKeybindControl(
    DeveloperTab,
    "Noclip",
    "Noclip"
)

CreateKeybindControl(
    DeveloperTab,
    "Infinite Jump",
    "InfiniteJump"
)

CreateKeybindControl(
    DeveloperTab,
    "Fullbright",
    "Fullbright"
)

CreateKeybindControl(
    DeveloperTab,
    "Anti AFK",
    "AntiAFK"
)

CreateKeybindControl(
    DeveloperTab,
    "Auto Sprint",
    "AutoSprint"
)

CreateKeybindControl(
    DeveloperTab,
    "Aimbot",
    "Aimbot"
)

--========================================================--
-- CONFIG UI
--========================================================--

DeveloperTab:CreateDivider()

DeveloperTab:CreateButton({
    name = "Copy Current Config",
    callback = function()
        Copy(
            EncodeConfig(
                BuildConfig()
            )
        )
    end,
})

DeveloperTab:CreateButton({
    name = "Save Current Config",
    callback = function()
        SaveConfig()
    end,
})

DeveloperTab:CreateButton({
    name = "Load Saved Config",
    callback = function()
        LoadConfig()
    end,
})

local ConfigInput =
    DeveloperTab:CreateInput({
        name = "Paste Config",
        value = "",
        placeholder = "Paste JSON config here...",
        callback = function()
        end,
    })

DeveloperTab:CreateButton({
    name = "Load Pasted Config",
    callback = function()
        local text = ConfigInput.value

        if type(text) ~= "string"
            or text == "" then
            return
        end

        local config =
            DecodeConfig(text)

        if config then
            ApplyConfig(config)
        end
    end,
})

DeveloperTab:CreateButton({
    name = "Copy Config Template",
    callback = function()
        Copy(
            EncodeConfig(
                BuildConfig()
            )
        )
    end,
})

DeveloperTab:CreateButton({
    name = "Reset Config",
    callback = function()
        local defaults = {
            Player = {
                WalkSpeed = 16,
                JumpPower = 50,
                InfiniteJump = false,
                Gravity = 196.2,
                CameraFOV = 70,
                FlyEnabled = false,
                FlySpeed = 75,
                Noclip = false,
                AutoSprint = false,
                Fullbright = false,
                AntiAFK = false,
            },

            ESP = {
                Enabled = false,
                NPCEnabled = false,
                Names = true,
                Distance = true,
                Health = true,
                Tracers = false,
                TeamColors = true,
                Rainbow = false,
                Outline = true,
                Fill = false,
                OutlineTransparency = 0,
                FillTransparency = 0.7,
                MaxDistance = 1000,

                PlayerColor =
                    ColorToTable(
                        Color3.fromRGB(
                            255,
                            255,
                            255
                        )
                    ),

                NPCColor =
                    ColorToTable(
                        Color3.fromRGB(
                            255,
                            170,
                            0
                        )
                    ),
            },

            Aimbot = {
                Enabled = false,
                UseAimKey = true,
                AimAtPlayers = true,
                AimAtNPCs = false,
                OnlyVisible = true,
                TargetPart = "Head",
                LockTarget = false,
                TeamCheck = false,
                IgnoreDead = true,
                FOV = 150,
                MaxDistance = 500,
                Smoothness = 15,
                Prediction = false,
                PredictionStrength = 0.1,
                ShowFOV = false,

                FOVColor =
                    ColorToTable(
                        Color3.fromRGB(
                            255,
                            255,
                            255
                        )
                    ),
            },

            Keybinds = {
                Fly = {
                    Key = "F",
                    Mode = "Toggle",
                },

                Noclip = {
                    Key = "N",
                    Mode = "Toggle",
                },

                InfiniteJump = {
                    Key = "J",
                    Mode = "Toggle",
                },

                Fullbright = {
                    Key = "B",
                    Mode = "Toggle",
                },

                AntiAFK = {
                    Key = "P",
                    Mode = "Toggle",
                },

                AutoSprint = {
                    Key = "LeftShift",
                    Mode = "Smart",
                },

                Aimbot = {
                    Key = "RMB",
                    Mode = "Hold",
                },
            },
        }

        ApplyConfig(defaults)
    end,
})

--========================================================--
-- ANTI AFK
--========================================================--

LocalPlayer.Idled:Connect(function()
    if not PlayerState.AntiAFK then
        return
    end

    pcall(function()
        local camera = GetCamera()

        if not camera then
            return
        end

        VirtualUser:Button2Down(
            Vector2.new(0, 0),
            camera.CFrame
        )

        task.wait(0.1)

        VirtualUser:Button2Up(
            Vector2.new(0, 0),
            camera.CFrame
        )
    end)
end)

--========================================================--
-- MAIN LOOP
--========================================================--

local FPS = 0
local FPSFrames = 0
local FPSTime = os.clock()

RunService.RenderStepped:Connect(function()
    FPSFrames += 1

    local now = os.clock()

    if now - FPSTime >= 1 then
        FPS = FPSFrames
        FPSFrames = 0
        FPSTime = now
    end

    -- Keybind-driven states.

    local fly =
        KeybindSystem.Bindings.Fly

    if fly
        and fly.Active ~= PlayerState.FlyEnabled then

        PlayerState.FlyEnabled = fly.Active

        if fly.Active then
            StartFly()
        else
            CleanupFly()
        end
    end

    local noclip =
        KeybindSystem.Bindings.Noclip

    if noclip then
        PlayerState.Noclip = noclip.Active
    end

    local jump =
        KeybindSystem.Bindings.InfiniteJump

    if jump then
        PlayerState.InfiniteJump = jump.Active
    end

    local bright =
        KeybindSystem.Bindings.Fullbright

    if bright then
        PlayerState.Fullbright = bright.Active
    end

    local afk =
        KeybindSystem.Bindings.AntiAFK

    if afk then
        PlayerState.AntiAFK = afk.Active
    end

    -- Movement.

    if Humanoid then
        if PlayerState.AutoSprint
            and KeybindSystem:IsActive(
                "AutoSprint"
            ) then

            Humanoid.WalkSpeed =
                math.max(
                    PlayerState.WalkSpeed,
                    16
                )
        else
            Humanoid.WalkSpeed =
                PlayerState.WalkSpeed
        end
    end

    ApplyCameraFOV()

    if PlayerState.Fullbright then
        ApplyFullbright()
    end

    if PlayerState.Noclip then
        UpdateNoclip()
    end

    UpdateFly()

    -- Target database only rescans when dirty.

    local rebuilt =
        RebuildTargetDatabase()

    if rebuilt then
        RequestESPRefresh()
    end

    -- ESP.

    RefreshESP()
    UpdateESP()

    -- FOV.

    UpdateFOV()

    -- Aimbot.

    if Aimbot.Enabled then
        local active = true

        if Aimbot.UseAimKey then
            active =
                KeybindSystem:IsActive(
                    "Aimbot"
                )
        end

        if active then
            if Aimbot.LockTarget
                and Aimbot.Target then

                local target =
                    Aimbot.Target

                if not target.Model
                    or not target.Model.Parent
                    or not target.Part
                    or not target.Part.Parent then

                    Aimbot.Target = nil
                end
            end

            if not Aimbot.Target then
                Aimbot.Target =
                    GetBestAimbotTarget()
            end

            if Aimbot.Target then
                AimAtTarget(
                    Aimbot.Target
                )
            end
        elseif not Aimbot.LockTarget then
            Aimbot.Target = nil
        end
    else
        Aimbot.Target = nil
    end

    -- Stats.

    if StatsLabel then
        local ping = "--"

        pcall(function()
            ping = math.floor(
                LocalPlayer:GetNetworkPing()
                * 1000
            )
        end)

        pcall(function()
            StatsLabel:Set(
                string.format(
                    "FPS: %d | Ping: %sms | Players: %d",
                    FPS,
                    tostring(ping),
                    #Players:GetPlayers()
                )
            )
        end)
    end
end)

--========================================================--
-- INITIALIZATION
--========================================================--

ApplyMovement()
ApplyGravity()
ApplyCameraFOV()
UpdateFOV()
RefreshESP()

task.delay(1, function()
    LoadConfig()

    task.wait(0.2)

    ApplyMovement()
    ApplyGravity()
    ApplyCameraFOV()
    UpdateFOV()

    RequestESPRefresh()
    RefreshESP()
end)

print(
    "[Axiom Player Tools] v1.62.13 BETA 13 loaded."
)

print(
    "[Axiom] Rayfield Gen2 UI initialized."
)

print(
    "[Axiom] Silent Aim removed."
)

print(
    "[Axiom] Object Selector ready."
)
```
