Tambah kan kode complex prediction yang lebih akurat dan kena terus pada local prediction
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local LocalPlayer = Players.LocalPlayer
local Mouse = game.Players.LocalPlayer:GetMouse()
local CamlockState = false

-- Function to calculate the average ping
local function CalculateAveragePing()
    local pings = {}
    for _, player in pairs(Players:GetPlayers()) do
        if player ~= LocalPlayer then
            local ping = player:FindFirstChild("Ping") and player.Ping.Value or 0
            table.insert(pings, ping)
        end
    end
    local totalPing = 0
    for _, ping in pairs(pings) do
        totalPing = totalPing + ping
    end
    return #pings > 0 and totalPing / #pings or 0
end

local Prediction = 0.192323 -- Initial prediction value
local Locked = true

getgenv().Key = "q"

-- Create a part to visualize the locked target
local VisualPart = Instance.new("Part")
VisualPart.Anchored = true
VisualPart.CanCollide = false
VisualPart.Transparency = 0.5
VisualPart.BrickColor = BrickColor.new("Bright red")
VisualPart.Shape = Enum.PartType.Ball
VisualPart.Size = Vector3.new(1, 1, 1)
VisualPart.Material = Enum.Material.Neon -- Set the material to neon
VisualPart.Parent = workspace

function FindNearestEnemy()
    local ClosestDistance, ClosestPlayer = math.huge, nil
    local CenterPosition =
        Vector2.new(
        game:GetService("GuiService"):GetScreenResolution().X / 2,
        game:GetService("GuiService"):GetScreenResolution().Y / 2
    )

    for _, Player in ipairs(game:GetService("Players"):GetPlayers()) do
        if Player ~= LocalPlayer then
            local Character = Player.Character
            if Character and Character:FindFirstChild("HumanoidRootPart") and Character.Humanoid.Health > 0 then
                local Position, IsVisibleOnViewport =
                    game:GetService("Workspace").CurrentCamera:WorldToViewportPoint(Character.HumanoidRootPart.Position)

                if IsVisibleOnViewport then
                    local Distance = (CenterPosition - Vector2.new(Position.X, Position.Y)).Magnitude
                    if Distance < ClosestDistance then
                        -- Perform Raycast to check for obstructions
                        local origin = workspace.CurrentCamera.CFrame.Position
                        local direction = (Character.HumanoidRootPart.Position - origin).Unit * 1000
                        local raycastParams = RaycastParams.new()
                        raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
                        raycastParams.FilterDescendantsInstances = {LocalPlayer.Character}

                        local raycastResult = workspace:Raycast(origin, direction, raycastParams)
                        if raycastResult and raycastResult.Instance:IsDescendantOf(Character) then
                            ClosestPlayer = Character
                            ClosestDistance = Distance
                        end
                    end
                end
            end
        end
    end

    return ClosestPlayer
end

local enemy = nil

-- Function to aim the camera at the nearest enemy's HumanoidRootPart
RunService.Heartbeat:Connect(
    function()
        if CamlockState == true then
            -- Update Prediction based on average ping
            local averagePing = CalculateAveragePing()
            Prediction = averagePing > 100 and (averagePing / 500) or 0.192324

            if enemy then
                local camera = workspace.CurrentCamera
                local aimPart = enemy.HumanoidRootPart
                
                -- Check if enemy is between jumping and falling
                local enemyHumanoid = enemy:FindFirstChildOfClass("Humanoid")
                if enemyHumanoid then
                    local isJumping = enemyHumanoid:GetState() == Enum.HumanoidStateType.Jumping
                    local isFreefall = enemyHumanoid:GetState() == Enum.HumanoidStateType.Freefall
                    local isFallingDown = enemyHumanoid:GetState() == Enum.HumanoidStateType.FallingDown
                    local isSeated = enemyHumanoid:GetState() == Enum.HumanoidStateType.Seated

                    if isJumping then
                        -- Vertical offset for jumping enemy
                        local jumpOffsetY = 0.01 -- Adjust as needed

                        aimPart = enemy.LowerTorso.Position + Vector3.new(0, jumpOffsetY, 0)
                    elseif isFreefall then
                        -- Add delay before activating the tool
                        delay(0.9, function() -- Adjust the delay time as needed
                            local LocalPlayerCharacter = LocalPlayer.Character
                            if LocalPlayerCharacter then
                                local tool = LocalPlayerCharacter:FindFirstChildWhichIsA("Tool")
                                if tool then
                                    tool:Activate()
                                end
                            end
                        end)
                    elseif isFallingDown or isSeated then
                        -- Do not activate the tool if the enemy is falling down or seated
                    else
                        -- Deactivate the tool when the enemy is on the ground
                        local LocalPlayerCharacter = LocalPlayer.Character
                        if LocalPlayerCharacter then
                            local tool = LocalPlayerCharacter:FindFirstChildWhichIsA("Tool")
                            if tool then
                                tool:Deactivate()
                            end
                        end
                    end
                end
                
                local predictedPosition = aimPart.Position + aimPart.Velocity * Prediction
                camera.CFrame = CFrame.new(camera.CFrame.p, predictedPosition)
                
                -- Update visual part position with prediction
                VisualPart.Position = predictedPosition

                -- Check if enemy's health is 5 or below
                if enemyHumanoid and enemyHumanoid.Health <= 5 then
                    CamlockState = false
                    enemy = nil
                    TextButton.Text = "Yx.GG Off :("
                    VisualPart.Position = Vector3.new(0, 0, 0) -- Hide visual part
                end
            end

            -- Check if local player's health is 2 or below
            local localHumanoid = LocalPlayer.Character and LocalPlayer.Character:FindFirstChildOfClass("Humanoid")
            if localHumanoid and localHumanoid.Health <= 2 then
                CamlockState = false
                enemy = nil
                TextButton.Text = "Yx.GG Off :("
                VisualPart.Position = Vector3.new(0, 0, 0) -- Hide visual part
            end
        end
    end
)

Mouse.KeyDown:Connect(function(k)
    if k == getgenv().Key then
        Locked = not Locked
        if Locked then
            enemy = FindNearestEnemy()
            CamlockState = true
            if enemy then
                VisualPart.Position = enemy.Position -- Show visual part
            end
        else
            if enemy ~= nil then
                enemy = nil
                CamlockState = false
                VisualPart.Position = Vector3.new(0, 0, 0) -- Hide visual part
            end
        end
    end
end)

local Hellbound = Instance.new("ScreenGui")
local Frame = Instance.new("Frame")
local UICorner = Instance.new("UICorner")
local Logo = Instance.new("ImageLabel")
local TextButton = Instance.new("TextButton")
local UICorner_2 = Instance.new("UICorner")

--Properties:

Hellbound.Name = "Ez GGs Clicks"
Hellbound.Parent = game.CoreGui
Hellbound.ZIndexBehavior = Enum.ZIndexBehavior.Sibling

Frame.Parent = Hellbound
Frame.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
Frame.BorderColor3 = Color3.fromRGB(0, 0, 0)
Frame.BorderSizePixel = 0
Frame.Position = UDim2.new(0.133798108, 0, 0.20107238, 0)
Frame.Size = UDim2.new(0, 150, 0, 50)
Frame.Active = true
Frame.Draggable = true

local function TopContainer()
    Frame.Position = UDim2.new(0.5, -Frame.AbsoluteSize.X / 2, 0, -Frame.AbsoluteSize.Y / 2)
end

TopContainer()
Frame:GetPropertyChangedSignal("AbsoluteSize"):Connect(TopContainer)

UICorner.Parent = Frame

Logo.Name = "Logo"
Logo.Parent = Frame
Logo.BackgroundColor3 = Color3.fromRGB(100, 255, 100)
Logo.BackgroundTransparency = 3.000
Logo.BorderColor3 = Color3.fromRGB(0, 0, 0)
Logo.BorderSizePixel = 0
Logo.Position = UDim2.new(0.326732665, 0, 0, 0)
Logo.Size = UDim2.new(0, 70, 0, 70)
Logo.Image = "rbxassetid://7129155278"
Logo.ImageTransparency = 0.300

TextButton.Parent = Frame
TextButton.BackgroundColor3 = Color3.fromRGB(101, 55, 229)
TextButton.BackgroundTransparency = 5.000
TextButton.BorderColor3 = Color3.fromRGB(0, 0, 0)
TextButton.BorderSizePixel = 0
TextButton.Position = UDim2.new(0.0792079195, 0, 0.18571429, 0)
TextButton.Size = UDim2.new(0, 120, 0, 30)
TextButton.Font = Enum.Font.SourceSansSemibold
TextButton.Text = "Ez GGs"
TextButton.TextColor3 = Color3.fromRGB(255, 255, 255)
TextButton.TextScaled = true
TextButton.TextSize = 18.000
TextButton.TextWrapped = true
local state = true
TextButton.MouseButton1Click:Connect(
    function()
        state = not state
        if not state then
            TextButton.Text = "Yx.GG On :)"
            CamlockState = true
            enemy = FindNearestEnemy()
            if enemy then
                VisualPart.Position = enemy.Position -- Show visual part
            end
        else
            TextButton.Text = "Yx.GG Off :("
            CamlockState = false
            enemy = nil
            VisualPart.Position = Vector3.new(0, 0, 0) -- Hide visual part
        end
    end
)