test
Key RequiredUniversal

test

Universal Scriptgfgfgvjgngfgfgvjgn 126 views 371 executesUpdated Jul 29, 2026
Unrated
00
Lua Script•756 lines (26388 chars)
-- ═══════════════════════════════════════════════════════════════
--  神罗天征 · 自瞄系统 v1.0
--  作者: AI生罗宝Luau
--  功能: 带GUI自瞄脚本,支持多队伍选择、自瞄圈大小/颜色调整
--  放置位置: StarterPlayer > StarterPlayerScripts (LocalScript)
-- ═══════════════════════════════════════════════════════════════

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Teams = game:GetService("Teams")
local TweenService = game:GetService("TweenService")
local StarterGui = game:GetService("StarterGui")
local CoreGui = game:GetService("CoreGui")

local LocalPlayer = Players.LocalPlayer
local Camera = workspace.CurrentCamera

-- ═══════════════════════════════════════════════════════════════
--  配置表
-- ═══════════════════════════════════════════════════════════════
local Config = {
    Enabled = false,
    FovRadius = 150,
    FovColor = Color3.fromRGB(255, 0, 0),
    AimPart = "Head",
    AimSmooth = 0.15,
    TeamCheck = true,
    WallCheck = true,
    SelectedTeams = {},
    AimKey = Enum.UserInputType.MouseButton2,
    ShowFov = true,
    MaxDistance = 1000,
}

-- 颜色映射表
local ColorMap = {
    ["红色"] = Color3.fromRGB(255, 0, 0),
    ["橙色"] = Color3.fromRGB(255, 165, 0),
    ["黄色"] = Color3.fromRGB(255, 255, 0),
    ["绿色"] = Color3.fromRGB(0, 255, 0),
    ["青色"] = Color3.fromRGB(0, 255, 255),
    ["蓝色"] = Color3.fromRGB(0, 0, 255),
    ["紫色"] = Color3.fromRGB(128, 0, 128),
}

local ColorNames = {"红色", "橙色", "黄色", "绿色", "青色", "蓝色", "紫色"}

-- ═══════════════════════════════════════════════════════════════
--  GUI 构建
-- ═══════════════════════════════════════════════════════════════
local function CreateGUI()
    -- 屏幕GUI
    local ScreenGui = Instance.new("ScreenGui")
    ScreenGui.Name = "AimbotGUI"
    ScreenGui.ResetOnSpawn = false
    ScreenGui.ZIndexBehavior = Enum.ZIndexBehavior.Sibling

    -- 尝试放入CoreGui(外挂注入器常用方式)
    local success = pcall(function()
        ScreenGui.Parent = CoreGui
    end)
    if not success then
        ScreenGui.Parent = LocalPlayer:WaitForChild("PlayerGui")
    end

    -- 主面板
    local MainFrame = Instance.new("Frame")
    MainFrame.Name = "MainPanel"
    MainFrame.Size = UDim2.new(0, 320, 0, 480)
    MainFrame.Position = UDim2.new(0, 20, 0.5, -240)
    MainFrame.BackgroundColor3 = Color3.fromRGB(20, 20, 25)
    MainFrame.BorderSizePixel = 0
    MainFrame.ClipsDescendants = true
    MainFrame.Parent = ScreenGui

    -- 圆角
    local UICorner = Instance.new("UICorner")
    UICorner.CornerRadius = UDim.new(0, 12)
    UICorner.Parent = MainFrame

    -- 阴影
    local Shadow = Instance.new("ImageLabel")
    Shadow.Name = "Shadow"
    Shadow.Size = UDim2.new(1, 30, 1, 30)
    Shadow.Position = UDim2.new(0, -15, 0, -15)
    Shadow.BackgroundTransparency = 1
    Shadow.Image = "rbxassetid://5554236805"
    Shadow.ImageColor3 = Color3.fromRGB(0, 0, 0)
    Shadow.ImageTransparency = 0.6
    Shadow.ScaleType = Enum.ScaleType.Slice
    Shadow.SliceCenter = Rect.new(23, 23, 277, 277)
    Shadow.ZIndex = -1
    Shadow.Parent = MainFrame

    -- 标题栏
    local TitleBar = Instance.new("Frame")
    TitleBar.Name = "TitleBar"
    TitleBar.Size = UDim2.new(1, 0, 0, 45)
    TitleBar.BackgroundColor3 = Color3.fromRGB(30, 30, 40)
    TitleBar.BorderSizePixel = 0
    TitleBar.Parent = MainFrame

    local TitleCorner = Instance.new("UICorner")
    TitleCorner.CornerRadius = UDim.new(0, 12)
    TitleCorner.Parent = TitleBar

    local TitleText = Instance.new("TextLabel")
    TitleText.Name = "Title"
    TitleText.Size = UDim2.new(1, -50, 1, 0)
    TitleText.Position = UDim2.new(0, 15, 0, 0)
    TitleText.BackgroundTransparency = 1
    TitleText.Text = "🎯 神罗天征 · 自瞄系统"
    TitleText.TextColor3 = Color3.fromRGB(255, 255, 255)
    TitleText.TextSize = 18
    TitleText.Font = Enum.Font.GothamBold
    TitleText.TextXAlignment = Enum.TextXAlignment.Left
    TitleText.Parent = TitleBar

    -- 关闭按钮
    local CloseBtn = Instance.new("TextButton")
    CloseBtn.Name = "CloseBtn"
    CloseBtn.Size = UDim2.new(0, 35, 0, 35)
    CloseBtn.Position = UDim2.new(1, -40, 0, 5)
    CloseBtn.BackgroundColor3 = Color3.fromRGB(200, 50, 50)
    CloseBtn.Text = "✕"
    CloseBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
    CloseBtn.TextSize = 16
    CloseBtn.Font = Enum.Font.GothamBold
    CloseBtn.Parent = TitleBar

    local CloseCorner = Instance.new("UICorner")
    CloseCorner.CornerRadius = UDim.new(0, 8)
    CloseCorner.Parent = CloseBtn

    -- 内容滚动区
    local ScrollFrame = Instance.new("ScrollingFrame")
    ScrollFrame.Name = "Content"
    ScrollFrame.Size = UDim2.new(1, -20, 1, -55)
    ScrollFrame.Position = UDim2.new(0, 10, 0, 50)
    ScrollFrame.BackgroundTransparency = 1
    ScrollFrame.ScrollBarThickness = 4
    ScrollFrame.ScrollBarImageColor3 = Color3.fromRGB(100, 100, 120)
    ScrollFrame.CanvasSize = UDim2.new(0, 0, 0, 600)
    ScrollFrame.Parent = MainFrame

    local UIList = Instance.new("UIListLayout")
    UIList.Padding = UDim.new(0, 10)
    UIList.SortOrder = Enum.SortOrder.LayoutOrder
    UIList.Parent = ScrollFrame

    -- ═══════════════════════════════════════════════════════
    --  辅助函数: 创建开关
    -- ═══════════════════════════════════════════════════════
    local function CreateToggle(name, default, callback)
        local Frame = Instance.new("Frame")
        Frame.Size = UDim2.new(1, 0, 0, 40)
        Frame.BackgroundTransparency = 1

        local Label = Instance.new("TextLabel")
        Label.Size = UDim2.new(0.6, 0, 1, 0)
        Label.BackgroundTransparency = 1
        Label.Text = name
        Label.TextColor3 = Color3.fromRGB(220, 220, 220)
        Label.TextSize = 14
        Label.Font = Enum.Font.Gotham
        Label.TextXAlignment = Enum.TextXAlignment.Left
        Label.Parent = Frame

        local ToggleBtn = Instance.new("TextButton")
        ToggleBtn.Size = UDim2.new(0, 50, 0, 26)
        ToggleBtn.Position = UDim2.new(1, -55, 0.5, -13)
        ToggleBtn.BackgroundColor3 = default and Color3.fromRGB(0, 200, 100) or Color3.fromRGB(80, 80, 90)
        ToggleBtn.Text = default and "开" or "关"
        ToggleBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
        ToggleBtn.TextSize = 13
        ToggleBtn.Font = Enum.Font.GothamBold
        ToggleBtn.Parent = Frame

        local ToggleCorner = Instance.new("UICorner")
        ToggleCorner.CornerRadius = UDim.new(0, 13)
        ToggleCorner.Parent = ToggleBtn

        local state = default
        ToggleBtn.MouseButton1Click:Connect(function()
            state = not state
            ToggleBtn.BackgroundColor3 = state and Color3.fromRGB(0, 200, 100) or Color3.fromRGB(80, 80, 90)
            ToggleBtn.Text = state and "开" or "关"
            if callback then callback(state) end
        end)

        Frame.Parent = ScrollFrame
        return ToggleBtn
    end

    -- ═══════════════════════════════════════════════════════
    --  辅助函数: 创建滑块
    -- ═══════════════════════════════════════════════════════
    local function CreateSlider(name, min, max, default, callback)
        local Frame = Instance.new("Frame")
        Frame.Size = UDim2.new(1, 0, 0, 60)
        Frame.BackgroundTransparency = 1

        local Label = Instance.new("TextLabel")
        Label.Size = UDim2.new(0.5, 0, 0, 20)
        Label.BackgroundTransparency = 1
        Label.Text = name
        Label.TextColor3 = Color3.fromRGB(220, 220, 220)
        Label.TextSize = 14
        Label.Font = Enum.Font.Gotham
        Label.TextXAlignment = Enum.TextXAlignment.Left
        Label.Parent = Frame

        local ValueLabel = Instance.new("TextLabel")
        ValueLabel.Size = UDim2.new(0.5, 0, 0, 20)
        ValueLabel.Position = UDim2.new(0.5, 0, 0, 0)
        ValueLabel.BackgroundTransparency = 1
        ValueLabel.Text = tostring(default)
        ValueLabel.TextColor3 = Color3.fromRGB(0, 200, 255)
        ValueLabel.TextSize = 14
        ValueLabel.Font = Enum.Font.GothamBold
        ValueLabel.TextXAlignment = Enum.TextXAlignment.Right
        ValueLabel.Parent = Frame

        local Track = Instance.new("Frame")
        Track.Size = UDim2.new(1, 0, 0, 8)
        Track.Position = UDim2.new(0, 0, 0, 35)
        Track.BackgroundColor3 = Color3.fromRGB(50, 50, 60)
        Track.BorderSizePixel = 0
        Track.Parent = Frame

        local TrackCorner = Instance.new("UICorner")
        TrackCorner.CornerRadius = UDim.new(0, 4)
        TrackCorner.Parent = Track

        local Fill = Instance.new("Frame")
        Fill.Size = UDim2.new((default - min) / (max - min), 0, 1, 0)
        Fill.BackgroundColor3 = Color3.fromRGB(0, 150, 255)
        Fill.BorderSizePixel = 0
        Fill.Parent = Track

        local FillCorner = Instance.new("UICorner")
        FillCorner.CornerRadius = UDim.new(0, 4)
        FillCorner.Parent = Fill

        local Knob = Instance.new("Frame")
        Knob.Size = UDim2.new(0, 16, 0, 16)
        Knob.Position = UDim2.new((default - min) / (max - min), -8, 0.5, -8)
        Knob.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
        Knob.BorderSizePixel = 0
        Knob.Parent = Track

        local KnobCorner = Instance.new("UICorner")
        KnobCorner.CornerRadius = UDim.new(1, 0)
        KnobCorner.Parent = Knob

        local dragging = false
        local function update(input)
            local pos = math.clamp((input.Position.X - Track.AbsolutePosition.X) / Track.AbsoluteSize.X, 0, 1)
            local value = math.floor(min + pos * (max - min))
            Fill.Size = UDim2.new(pos, 0, 1, 0)
            Knob.Position = UDim2.new(pos, -8, 0.5, -8)
            ValueLabel.Text = tostring(value)
            if callback then callback(value) end
        end

        Knob.InputBegan:Connect(function(input)
            if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
                dragging = true
            end
        end)

        UserInputService.InputChanged:Connect(function(input)
            if dragging and (input.UserInputType == Enum.UserInputType.MouseMovement or input.UserInputType == Enum.UserInputType.Touch) then
                update(input)
            end
        end)

        UserInputService.InputEnded:Connect(function(input)
            if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
                dragging = false
            end
        end)

        Track.InputBegan:Connect(function(input)
            if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
                update(input)
            end
        end)

        Frame.Parent = ScrollFrame
    end

    -- ═══════════════════════════════════════════════════════
    --  辅助函数: 创建下拉选择
    -- ═══════════════════════════════════════════════════════
    local function CreateDropdown(name, options, default, callback)
        local Frame = Instance.new("Frame")
        Frame.Size = UDim2.new(1, 0, 0, 40)
        Frame.BackgroundTransparency = 1

        local Label = Instance.new("TextLabel")
        Label.Size = UDim2.new(0.4, 0, 1, 0)
        Label.BackgroundTransparency = 1
        Label.Text = name
        Label.TextColor3 = Color3.fromRGB(220, 220, 220)
        Label.TextSize = 14
        Label.Font = Enum.Font.Gotham
        Label.TextXAlignment = Enum.TextXAlignment.Left
        Label.Parent = Frame

        local DropdownBtn = Instance.new("TextButton")
        DropdownBtn.Size = UDim2.new(0, 140, 0, 30)
        DropdownBtn.Position = UDim2.new(1, -145, 0.5, -15)
        DropdownBtn.BackgroundColor3 = Color3.fromRGB(50, 50, 60)
        DropdownBtn.Text = default
        DropdownBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
        DropdownBtn.TextSize = 13
        DropdownBtn.Font = Enum.Font.Gotham
        DropdownBtn.Parent = Frame

        local DropdownCorner = Instance.new("UICorner")
        DropdownCorner.CornerRadius = UDim.new(0, 6)
        DropdownCorner.Parent = DropdownBtn

        local Arrow = Instance.new("TextLabel")
        Arrow.Size = UDim2.new(0, 20, 1, 0)
        Arrow.Position = UDim2.new(1, -20, 0, 0)
        Arrow.BackgroundTransparency = 1
        Arrow.Text = "▼"
        Arrow.TextColor3 = Color3.fromRGB(180, 180, 180)
        Arrow.TextSize = 12
        Arrow.Parent = DropdownBtn

        local ListFrame = Instance.new("Frame")
        ListFrame.Size = UDim2.new(0, 140, 0, #options * 30)
        ListFrame.Position = UDim2.new(0, 0, 1, 5)
        ListFrame.BackgroundColor3 = Color3.fromRGB(40, 40, 50)
        ListFrame.BorderSizePixel = 0
        ListFrame.Visible = false
        ListFrame.ZIndex = 10
        ListFrame.Parent = DropdownBtn

        local ListCorner = Instance.new("UICorner")
        ListCorner.CornerRadius = UDim.new(0, 6)
        ListCorner.Parent = ListFrame

        for i, option in ipairs(options) do
            local OptionBtn = Instance.new("TextButton")
            OptionBtn.Size = UDim2.new(1, 0, 0, 30)
            OptionBtn.Position = UDim2.new(0, 0, 0, (i - 1) * 30)
            OptionBtn.BackgroundColor3 = Color3.fromRGB(40, 40, 50)
            OptionBtn.Text = option
            OptionBtn.TextColor3 = Color3.fromRGB(220, 220, 220)
            OptionBtn.TextSize = 13
            OptionBtn.Font = Enum.Font.Gotham
            OptionBtn.ZIndex = 11
            OptionBtn.Parent = ListFrame

            OptionBtn.MouseEnter:Connect(function()
                OptionBtn.BackgroundColor3 = Color3.fromRGB(60, 60, 80)
            end)
            OptionBtn.MouseLeave:Connect(function()
                OptionBtn.BackgroundColor3 = Color3.fromRGB(40, 40, 50)
            end)
            OptionBtn.MouseButton1Click:Connect(function()
                DropdownBtn.Text = option
                ListFrame.Visible = false
                if callback then callback(option) end
            end)
        end

        DropdownBtn.MouseButton1Click:Connect(function()
            ListFrame.Visible = not ListFrame.Visible
        end)

        Frame.Parent = ScrollFrame
        return DropdownBtn
    end

    -- ═══════════════════════════════════════════════════════
    --  辅助函数: 创建队伍多选
    -- ═══════════════════════════════════════════════════════
    local function CreateTeamSelector()
        local Frame = Instance.new("Frame")
        Frame.Size = UDim2.new(1, 0, 0, 120)
        Frame.BackgroundTransparency = 1

        local Label = Instance.new("TextLabel")
        Label.Size = UDim2.new(1, 0, 0, 20)
        Label.BackgroundTransparency = 1
        Label.Text = "🛡️ 目标队伍选择(可多选)"
        Label.TextColor3 = Color3.fromRGB(220, 220, 220)
        Label.TextSize = 14
        Label.Font = Enum.Font.GothamBold
        Label.TextXAlignment = Enum.TextXAlignment.Left
        Label.Parent = Frame

        local TeamContainer = Instance.new("Frame")
        TeamContainer.Name = "TeamContainer"
        TeamContainer.Size = UDim2.new(1, 0, 0, 90)
        TeamContainer.Position = UDim2.new(0, 0, 0, 25)
        TeamContainer.BackgroundTransparency = 1
        TeamContainer.Parent = Frame

        local TeamList = Instance.new("UIListLayout")
        TeamList.Padding = UDim.new(0, 5)
        TeamList.SortOrder = Enum.SortOrder.LayoutOrder
        TeamList.Parent = TeamContainer

        local teamButtons = {}

        local function RefreshTeams()
            -- 清除旧按钮
            for _, btn in pairs(teamButtons) do
                btn:Destroy()
            end
            teamButtons = {}

            for _, team in ipairs(Teams:GetTeams()) do
                local TeamBtn = Instance.new("TextButton")
                TeamBtn.Size = UDim2.new(1, 0, 0, 28)
                TeamBtn.BackgroundColor3 = Config.SelectedTeams[team.Name] and team.TeamColor.Color or Color3.fromRGB(60, 60, 70)
                TeamBtn.Text = "  " .. team.Name
                TeamBtn.TextColor3 = Color3.fromRGB(255, 255, 255)
                TeamBtn.TextSize = 13
                TeamBtn.Font = Enum.Font.Gotham
                TeamBtn.TextXAlignment = Enum.TextXAlignment.Left
                TeamBtn.Parent = TeamContainer

                local TeamCorner = Instance.new("UICorner")
                TeamCorner.CornerRadius = UDim.new(0, 6)
                TeamCorner.Parent = TeamBtn

                local Indicator = Instance.new("Frame")
                Indicator.Size = UDim2.new(0, 12, 0, 12)
                Indicator.Position = UDim2.new(1, -20, 0.5, -6)
                Indicator.BackgroundColor3 = Config.SelectedTeams[team.Name] and Color3.fromRGB(0, 255, 100) or Color3.fromRGB(80, 80, 90)
                Indicator.BorderSizePixel = 0
                Indicator.Parent = TeamBtn

                local IndCorner = Instance.new("UICorner")
                IndCorner.CornerRadius = UDim.new(1, 0)
                IndCorner.Parent = Indicator

                TeamBtn.MouseButton1Click:Connect(function()
                    Config.SelectedTeams[team.Name] = not Config.SelectedTeams[team.Name]
                    TeamBtn.BackgroundColor3 = Config.SelectedTeams[team.Name] and team.TeamColor.Color or Color3.fromRGB(60, 60, 70)
                    Indicator.BackgroundColor3 = Config.SelectedTeams[team.Name] and Color3.fromRGB(0, 255, 100) or Color3.fromRGB(80, 80, 90)
                end)

                table.insert(teamButtons, TeamBtn)
            end
        end

        RefreshTeams()
        Teams.ChildAdded:Connect(RefreshTeams)
        Teams.ChildRemoved:Connect(RefreshTeams)

        Frame.Parent = ScrollFrame
    end

    -- ═══════════════════════════════════════════════════════
    --  辅助函数: 创建分隔线
    -- ═══════════════════════════════════════════════════════
    local function CreateDivider()
        local Line = Instance.new("Frame")
        Line.Size = UDim2.new(1, 0, 0, 1)
        Line.BackgroundColor3 = Color3.fromRGB(60, 60, 70)
        Line.BorderSizePixel = 0
        Line.Parent = ScrollFrame
    end

    -- ═══════════════════════════════════════════════════════
    --  构建GUI内容
    -- ═══════════════════════════════════════════════════════

    -- 总开关
    CreateToggle("🔥 自瞄总开关", false, function(state)
        Config.Enabled = state
        StarterGui:SetCore("SendNotification", {
            Title = "神罗天征",
            Text = state and "自瞄已启用" or "自瞄已关闭",
            Duration = 2,
        })
    end)

    CreateDivider()

    -- 自瞄圈显示
    CreateToggle("👁️ 显示自瞄圈", true, function(state)
        Config.ShowFov = state
    end)

    -- 队伍检测
    CreateToggle("🛡️ 队伍检测(只瞄非友军)", true, function(state)
        Config.TeamCheck = state
    end)

    -- 穿墙检测
    CreateToggle("🧱 穿墙检测", true, function(state)
        Config.WallCheck = state
    end)

    CreateDivider()

    -- 自瞄圈大小
    CreateSlider("📐 自瞄圈大小", 30, 400, 150, function(value)
        Config.FovRadius = value
    end)

    -- 平滑度
    CreateSlider("🎯 瞄准平滑度", 1, 50, 15, function(value)
        Config.AimSmooth = value / 100
    end)

    -- 最大距离
    CreateSlider("📏 最大瞄准距离", 50, 2000, 1000, function(value)
        Config.MaxDistance = value
    end)

    CreateDivider()

    -- 颜色选择
    CreateDropdown("🎨 自瞄圈颜色", ColorNames, "红色", function(colorName)
        Config.FovColor = ColorMap[colorName]
    end)

    CreateDivider()

    -- 瞄准部位
    CreateDropdown("🎯 瞄准部位", {"Head", "HumanoidRootPart", "Torso", "LeftArm", "RightArm"}, "Head", function(part)
        Config.AimPart = part
    end)

    CreateDivider()

    -- 队伍选择器
    CreateTeamSelector()

    -- 关闭按钮事件
    CloseBtn.MouseButton1Click:Connect(function()
        ScreenGui.Enabled = false
    end)

    -- 拖拽功能
    local dragging = false
    local dragStart, startPos

    TitleBar.InputBegan:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
            dragging = true
            dragStart = input.Position
            startPos = MainFrame.Position
        end
    end)

    UserInputService.InputChanged:Connect(function(input)
        if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
            local delta = input.Position - dragStart
            MainFrame.Position = UDim2.new(
                startPos.X.Scale, startPos.X.Offset + delta.X,
                startPos.Y.Scale, startPos.Y.Offset + delta.Y
            )
        end
    end)

    UserInputService.InputEnded:Connect(function(input)
        if input.UserInputType == Enum.UserInputType.MouseButton1 then
            dragging = false
        end
    end)

    -- 快捷键显示/隐藏GUI (右Shift键)
    UserInputService.InputBegan:Connect(function(input, gameProcessed)
        if not gameProcessed and input.KeyCode == Enum.KeyCode.RightShift then
            ScreenGui.Enabled = not ScreenGui.Enabled
        end
    end)

    return ScreenGui
end

-- ═══════════════════════════════════════════════════════════════
--  自瞄圈绘制
-- ═══════════════════════════════════════════════════════════════
local FovCircle = Drawing.new("Circle")
FovCircle.Visible = true
FovCircle.Thickness = 2
FovCircle.NumSides = 64
FovCircle.Filled = false
FovCircle.Radius = Config.FovRadius
FovCircle.Color = Config.FovColor

-- ═══════════════════════════════════════════════════════════════
--  核心自瞄逻辑
-- ═══════════════════════════════════════════════════════════════
local function GetClosestPlayer()
    local closestPlayer = nil
    local shortestDistance = math.huge
    local screenCenter = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2)

    for _, player in ipairs(Players:GetPlayers()) do
        if player == LocalPlayer then continue end

        local character = player.Character
        if not character then continue end

        local humanoid = character:FindFirstChildOfClass("Humanoid")
        if not humanoid or humanoid.Health <= 0 then continue end

        -- 队伍检测
        if Config.TeamCheck then
            local localTeam = LocalPlayer.Team
            local targetTeam = player.Team

            -- 如果选择了特定队伍
            local teamSelected = false
            for teamName, selected in pairs(Config.SelectedTeams) do
                if selected and targetTeam and targetTeam.Name == teamName then
                    teamSelected = true
                    break
                end
            end

            -- 如果没有选择任何队伍,默认瞄准非友军
            local hasSelection = false
            for _, v in pairs(Config.SelectedTeams) do
                if v then hasSelection = true break end
            end

            if hasSelection and not teamSelected then
                continue
            elseif not hasSelection and localTeam and targetTeam and localTeam == targetTeam then
                continue
            end
        end

        local aimPart = character:FindFirstChild(Config.AimPart)
        if not aimPart then
            aimPart = character:FindFirstChild("Head")
            if not aimPart then continue end
        end

        -- 世界坐标转屏幕坐标
        local worldPos = aimPart.Position
        local screenPos, onScreen = Camera:WorldToViewportPoint(worldPos)

        if not onScreen then continue end

        -- 距离检测
        local distance = (LocalPlayer.Character and LocalPlayer.Character:FindFirstChild("HumanoidRootPart")) 
            and (LocalPlayer.Character.HumanoidRootPart.Position - worldPos).Magnitude 
            or 0

        if distance > Config.MaxDistance then continue end

        -- 自瞄圈检测
        local screenPos2D = Vector2.new(screenPos.X, screenPos.Y)
        local distFromCenter = (screenPos2D - screenCenter).Magnitude

        if distFromCenter <= Config.FovRadius and distFromCenter < shortestDistance then
            -- 穿墙检测
            if Config.WallCheck then
                local rayParams = RaycastParams.new()
                rayParams.FilterDescendantsInstances = {LocalPlayer.Character, character}
                rayParams.FilterType = Enum.RaycastFilterType.Blacklist

                local rayResult = workspace:Raycast(Camera.CFrame.Position, (worldPos - Camera.CFrame.Position).Unit * distance, rayParams)
                if rayResult then continue end
            end

            shortestDistance = distFromCenter
            closestPlayer = player
        end
    end

    return closestPlayer
end

-- ═══════════════════════════════════════════════════════════════
--  瞄准函数
-- ═══════════════════════════════════════════════════════════════
local function AimAt(target)
    if not target or not target.Character then return end

    local aimPart = target.Character:FindFirstChild(Config.AimPart)
    if not aimPart then
        aimPart = target.Character:FindFirstChild("Head")
        if not aimPart then return end
    end

    local targetPos = aimPart.Position
    local cameraCF = Camera.CFrame
    local targetCF = CFrame.new(cameraCF.Position, targetPos)

    -- 平滑瞄准
    Camera.CFrame = cameraCF:Lerp(targetCF, Config.AimSmooth)
end

-- ═══════════════════════════════════════════════════════════════
--  主循环
-- ═══════════════════════════════════════════════════════════════
local aiming = false

UserInputService.InputBegan:Connect(function(input, gameProcessed)
    if not gameProcessed and input.UserInputType == Config.AimKey then
        aiming = true
    end
end)

UserInputService.InputEnded:Connect(function(input)
    if input.UserInputType == Config.AimKey then
        aiming = false
    end
end)

RunService.RenderStepped:Connect(function()
    -- 更新自瞄圈
    FovCircle.Visible = Config.ShowFov
    FovCircle.Radius = Config.FovRadius
    FovCircle.Color = Config.FovColor
    FovCircle.Position = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2)

    -- 自瞄逻辑
    if Config.Enabled and aiming then
        local target = GetClosestPlayer()
        if target then
            AimAt(target)
            FovCircle.Color = Color3.fromRGB(0, 255, 100) -- 锁定目标时变绿
        else
            FovCircle.Color = Config.FovColor
        end
    else
        FovCircle.Color = Config.FovColor
    end
end)

-- ═══════════════════════════════════════════════════════════════
--  初始化
-- ═══════════════════════════════════════════════════════════════
CreateGUI()

-- 初始化通知
task.delay(1, function()
    pcall(function()
        StarterGui:SetCore("SendNotification", {
            Title = "神罗天征 · 自瞄系统",
            Text = "按 右Shift 键显示/隐藏面板 | 按住右键自瞄",
            Duration = 5,
            Icon = "rbxassetid://4483345998",
        })
    end)
end)

print("[神罗天征] 自瞄系统已加载完成")

Features & Information

Functional features: Chinese GUI interface, which can be dragged and moved Multi-team selection (check the team you want to aim at, and you can select multiple teams) The size of the self-aiming ring is adjustable (30-400 pixels) Self-aiming ring color can be selected in seven colors (red, orange, yellow, green, blue, blue and purple) Aiming smoothness adjustment Maximum aiming distance limit Through-wall detection switch Team detection switch Selection of aiming position (head/trunk/limbs) Automatically identify all teams in the game.
#test

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts