Skip to content
TheChatArchiveThe Chat Archive
o1-mini-2024-09-12· OpenAIAi2 WildChat-4.8M (AI2)

Further enhance and add in an advanced predictive algorithm and replace the auto-block…

  1. User

    Further enhance and add in an advanced predictive algorithm and replace the auto-block method with heartbeat so it wouldn't be framerate dependent. Also, make it so when it detects these animations close to your humanoid proximity, it'll block and track the humanoidrootpart that's playing this animations:

    Left Dash: rbxassetid://10480796021 Right Dash: rbxassetid://10480793962 Front Dash: rbxassetid://10479335397 Back Dash: rbxassetid://10491993682

    local players = game:GetService("Players")
    local plr = players.LocalPlayer
    local cd = false
    local Settings = {
        Autoparry = { Toggle = true, Range = 25, Delay = 0,Fov = 180, Facing = false,Dodgerange = 3,Aimhelper = false,},ESP = { Toggle = false, Config = {} },
        Tpaura = {Toggle = false,},
    }
    
    local anims = {
        --saitama
        ["rbxassetid://10469493270"] = { [1] = 0, [2] = 0.30 },
        ["rbxassetid://10469630950"] = { [1] = 0, [2] = 0.30 },
        ["rbxassetid://10469639222"] = { [1] = 0, [2] = 0.30 },
        ["rbxassetid://10469643643"] = { [1] = 0, [2] = 0.30 },
        --hunter
        ["rbxassetid://13532562418"] = { [1] = 0, [2] = 0.30 },
        ["rbxassetid://13532600125"] = { [1] = 0, [2] = 0.30 },
        ["rbxassetid://13532604085"] = { [1] = 0, [2] = 0.30 },
        ["rbxassetid://13294471966"] = { [1] = 0, [2] = 0.30 },
        --cyborg
        ["rbxassetid://13491635433"] = { [1] = 0, [2] = 0.30 },
        ["rbxassetid://13296577783"] = { [1] = 0, [2] = 0.30 },
        ["rbxassetid://13295919399"] = { [1] = 0, [2] = 0.30 },
        ["rbxassetid://13295936866"] = { [1] = 0, [2] = 0.30 },
        --ninja
        ["rbxassetid://13370310513"] = { [1] = 0, [2] = 0.30 },
        ["rbxassetid://13390230973"] = { [1] = 0, [2] = 0.30 },
        ["rbxassetid://13378751717"] = { [1] = 0, [2] = 0.30 },
        ["rbxassetid://13378708199"] = { [1] = 0, [2] = 0.30 },
        abilities = {
        }
    }
    local dodges = {
        ["rbxassetid://10479335397"] = { [1] = 0, [2] = 0.50 }, 
        ["rbxassetid://13380255751"] = { [1] = 0, [2] = 0.50 }
    }
    local barrages = {
        ["rbxassetid://10466974800"] = { [1] = 0.20, [2] = 1.80 },
        ["rbxassetid://12534735382"] = { [1] = 0.20, [2] = 1.80 }
    }
    local abilities = {
        ["rbxassetid://10468665991"] = { [1] = 0.15, [2] = 0.60 },
        ["rbxassetid://13376869471"] = { [1] = 0.05, [2] = 1 },
        ["rbxassetid://13376962659"] = { [1] = 0, [2] = 2 },
        ["rbxassetid://12296882427"] = { [1] = 0.05, [2] = 1 },--sonic
        ["rbxassetid://13309500827"] = { [1] = 0.05, [2] = 1 },--sonic
        ["rbxassetid://13365849295"] = { [1] = 0, [2] = 1 },--sonic
        ["rbxassetid://13377153603"] = { [1] = 0, [2] = 1 },--soni
        ["rbxassetid://12509505723"] = { [1] = 0.09, [2] = 2 }, -- dash for cyborg lmao
    
    }
    
    local closestplr, anim, plrDirection, unit, value,dodge
    function closest()
        closestplr = {}
        for i, v in next, players:GetChildren() do -- we want to use GetChildren instead of GetPlayers because we love children (written by mac)
            if v.Character and plr.Character:WaitForChild("HumanoidRootPart", 1) and v ~= plr and v.Character ~= plr.Character and v.Character:FindFirstChild("HumanoidRootPart")
                and (v.Character.HumanoidRootPart.Position - plr.Character.HumanoidRootPart.Position).Magnitude < Settings.Autoparry.Range
            then
                table.insert(closestplr, v)
            end
        end
        return closestplr
    end
    
    
    
    function attackchecker()
        for i,Anim in next, plr.Character.Humanoid.Animator:GetPlayingAnimationTracks() do
            z = anims[Anim.Animation.AnimationId] 
            q = dodges[Anim.Animation.AnimationId]
            j = abilities[Anim.Animation.AnimationId]
            k =  barrages[Anim.Animation.AnimationId]
            if z or q or j or k then  return true
            else return false
            end
        end
    end
    
    function isfacing(object)
        if Settings.Autoparry.Toggle then
            if Settings.Autoparry.Facing then
                plrDirection = plr.Character.Head.CFrame.LookVector
                unit = (object.Head.CFrame.p - plr.Character.Head.CFrame.p).Unit
                value = math.pow((plrDirection - unit).Magnitude / 2, 2)
                if value >= Settings.Autoparry.Fov / 360 then
                    return false
                else
                    return true
                end
            else
                return true
            end
        end
    end 
    
    function allowed(enemy)
        if not plr.Character:FindFirstChild("M1ing") and not attackchecker() and isfacing(enemy) then 
            return true
        end
    end
    
    local durations = {
        ["anim" ] = 0.3,
        ["dodge" ] = 0.9,
        ["barrage" ] = 0.9,
        ["ability" ] = 0.6,
    }
    
    function def(action)
        if cd then
            return
    end
        task.wait(Settings.Autoparry.Delay)
    print("parry attempt".."|"..action)
        cd = true
        plr.Character.Communicate:FireServer({["Goal"] = "KeyPress", ["Key"] = Enum.KeyCode.F})
        task.wait(durations[action])
        plr.Character.Communicate:FireServer({["Goal"] = "KeyRelease",["Key"] = Enum.KeyCode.F})
        cd = false
    end
    
    function barragechecker(enemy)
        if enemy:FindFirstChild("BarrageBind") then
            return true
        else
            return false
        end
    end
    
    function lookat(enemy)
        if Settings.Autoparry.Aimhelper then
            plr.Character.HumanoidRootPart.CFrame = CFrame.lookAt(plr.Character.HumanoidRootPart.Position, enemy.HumanoidRootPart.Position)
        end
    end
    
    function parry()
        for i, c in closest() do
            if c and plr.Character:WaitForChild("HumanoidRootPart", 2) and c.Character and c.Character:FindFirstChild("Humanoid") and c.Character.Humanoid:FindFirstChild("Animator")
            then
                for i, v in next, c.Character.Humanoid.Animator:GetPlayingAnimationTracks() do
                    anim = anims[v.Animation.AnimationId] 
                    dodge = dodges[v.Animation.AnimationId]
                    ability = abilities[v.Animation.AnimationId]
                    barrage = barrages[v.Animation.AnimationId]
                    if allowed(c.Character) and  anim  and v.TimePosition >= anim[1] and v.TimePosition <= anim[2] then
                        task.spawn(function()
                            def("anim")
                            lookat(c.Character)
                        end)
                    elseif allowed(c.Character) and dodge  and v.TimePosition > dodge[1] and v.TimePosition < dodge[2]   then
                        task.spawn(function()
                            def("dodge")
                            lookat(c.Character)
                        end)
                    elseif allowed(c.Character) and  barrage and v.TimePosition > barrage[1] and v.TimePosition < barrage[2]   then
                        task.spawn(function()
                            def("barrage")
                            lookat(c.Character)
                        end)
                    elseif allowed(c.Character) and ability and v.TimePosition > ability[1] and v.TimePosition < ability[2]  then
                        task.spawn(function()
                            def("ability")
                            lookat(c.Character)
                        end)
                    end
                end
             end
        end
    end
    
    
    
    task.spawn(function()
        game:GetService("RunService").RenderStepped:Connect(function()
            if Settings.Autoparry.Toggle then
                parry()
            end
        end)
    end)
    
    warn("Executed")
    
  2. Assistant

    Certainly! Below is an enhanced version of your Roblox Lua script incorporating the requested features:

    1. Advanced Predictive Algorithm: Uses opponent's velocity and position to predict future positions.
    2. Heartbeat Replacement: Utilizes RunService.Heartbeat instead of RenderStepped to avoid frame rate dependency.
    3. Animation Detection and Tracking: Specifically monitors the provided dash animations and responds appropriately.

    Enhanced Lua Script

    local Players = game:GetService("Players")
    local RunService = game:GetService("RunService")
    local plr = Players.LocalPlayer
    local debounce = false
    
    local Settings = {
        Autoparry = {
            Toggle = true,
            Range = 25,
            Delay = 0,
            Fov = 180,
            Facing = false,
            Dodgerange = 3,
            Aimhelper = false,
        },
        ESP = {
            Toggle = false,
            Config = {}
        },
        Tpaura = {
            Toggle = false,
        },
    }
    
    local trackedAnimations = {
        -- Saitama Animations
        ["rbxassetid://10469493270"] = { Type = "anim", Range = 0.30 },
        ["rbxassetid://10469630950"] = { Type = "anim", Range = 0.30 },
        ["rbxassetid://10469639222"] = { Type = "anim", Range = 0.30 },
        ["rbxassetid://10469643643"] = { Type = "anim", Range = 0.30 },
        -- Hunter Animations
        ["rbxassetid://13532562418"] = { Type = "anim", Range = 0.30 },
        ["rbxassetid://13532600125"] = { Type = "anim", Range = 0.30 },
        ["rbxassetid://13532604085"] = { Type = "anim", Range = 0.30 },
        ["rbxassetid://13294471966"] = { Type = "anim", Range = 0.30 },
        -- Cyborg Animations
        ["rbxassetid://13491635433"] = { Type = "anim", Range = 0.30 },
        ["rbxassetid://13296577783"] = { Type = "anim", Range = 0.30 },
        ["rbxassetid://13295919399"] = { Type = "anim", Range = 0.30 },
        ["rbxassetid://13295936866"] = { Type = "anim", Range = 0.30 },
        -- Ninja Animations
        ["rbxassetid://13370310513"] = { Type = "anim", Range = 0.30 },
        ["rbxassetid://13390230973"] = { Type = "anim", Range = 0.30 },
        ["rbxassetid://13378751717"] = { Type = "anim", Range = 0.30 },
        ["rbxassetid://13378708199"] = { Type = "anim", Range = 0.30 },
        -- Dashes (Specific Animations to Block and Track)
        ["rbxassetid://10480796021"] = { Type = "dash", Range = 0.50 },
        ["rbxassetid://10480793962"] = { Type = "dash", Range = 0.50 },
        ["rbxassetid://10479335397"] = { Type = "dash", Range = 0.50 },
        ["rbxassetid://10491993682"] = { Type = "dash", Range = 0.50 },
        -- Abilities
        ["rbxassetid://10468665991"] = { Type = "ability", Range = 0.60 },
        ["rbxassetid://13376869471"] = { Type = "ability", Range = 1.00 },
        ["rbxassetid://13376962659"] = { Type = "ability", Range = 2.00 },
        ["rbxassetid://12296882427"] = { Type = "ability", Range = 1.00 }, -- Sonic
        ["rbxassetid://13309500827"] = { Type = "ability", Range = 1.00 }, -- Sonic
        ["rbxassetid://13365849295"] = { Type = "ability", Range = 1.00 }, -- Sonic
        ["rbxassetid://13377153603"] = { Type = "ability", Range = 1.00 }, -- Sonic
        ["rbxassetid://12509505723"] = { Type = "dash", Range = 2.00 }, -- Dash for Cyborg
    }
    
    local function getClosestPlayers()
        local closestPlayers = {}
        if not plr.Character or not plr.Character:FindFirstChild("HumanoidRootPart") then
            return closestPlayers
        end
    
        local plrPos = plr.Character.HumanoidRootPart.Position
    
        for _, v in ipairs(Players:GetPlayers()) do
            if v ~= plr and v.Character and v.Character:FindFirstChild("HumanoidRootPart") then
                local distance = (v.Character.HumanoidRootPart.Position - plrPos).Magnitude
                if distance <= Settings.Autoparry.Range then
                    table.insert(closestPlayers, v)
                end
            end
        end
    
        return closestPlayers
    end
    
    local function isPlayerFacing(plrChar, targetChar)
        if not Settings.Autoparry.Facing then
            return true
        end
    
        local plrLookVector = plrChar.Head.CFrame.LookVector
        local direction = (targetChar.Head.Position - plrChar.Head.Position).Unit
        local dotProduct = plrLookVector:Dot(direction)
        local angle = math.deg(math.acos(dotProduct))
    
        return angle <= Settings.Autoparry.Fov / 2
    end
    
    local function canParry(enemy)
        if plr.Character:FindFirstChild("M1ing") then
            return false
        end
    
        if not isPlayerFacing(plr.Character, enemy.Character) then
            return false
        end
    
        return true
    end
    
    local function performParry(actionType, duration)
        if debounce then return end
        debounce = true
    
        print("Parry attempt | " .. actionType)
    
        plr.Character:FindFirstChild("Communicate"):FireServer({
            ["Goal"] = "KeyPress",
            ["Key"] = Enum.KeyCode.F
        })
    
        delay(duration, function()
            plr.Character:FindFirstChild("Communicate"):FireServer({
                ["Goal"] = "KeyRelease",
                ["Key"] = Enum.KeyCode.F
            })
            debounce = false
        end)
    end
    
    local function predictPosition(enemy)
        if not enemy.Character or not enemy.Character:FindFirstChild("HumanoidRootPart") then
            return enemy.Character and enemy.Character.HumanoidRootPart.Position or nil
        end
    
        local hrp = enemy.Character.HumanoidRootPart
        local velocity = enemy.Character.HumanoidRootPart.Velocity
        local predictionTime = 0.5 -- seconds ahead
    
        return hrp.Position + velocity * predictionTime
    end
    
    local function lookAt(position)
        if Settings.Autoparry.Aimhelper and plr.Character:FindFirstChild("HumanoidRootPart") then
            local hrp = plr.Character.HumanoidRootPart
            hrp.CFrame = CFrame.lookAt(hrp.Position, position)
        end
    end
    
    local function handleAnimations(enemy)
        if not enemy.Character or not enemy.Character:FindFirstChild("Humanoid") then return end
        local animator = enemy.Character.Humanoid:FindFirstChild("Animator")
        if not animator then return end
    
        for _, track in ipairs(animator:GetPlayingAnimationTracks()) do
            local animInfo = trackedAnimations[track.Animation.AnimationId]
            if animInfo then
                local currentTime = track.TimePosition
                if currentTime >= 0 and currentTime <= animInfo.Range then
                    if canParry(enemy) then
                        performParry(animInfo.Type, animInfo.Range)
                        local predictedPos = predictPosition(enemy)
                        if predictedPos then
                            lookAt(predictedPos)
                        end
                    end
                end
            end
        end
    end
    
    local function parryLogic()
        if not Settings.Autoparry.Toggle then return end
    
        local closestPlayers = getClosestPlayers()
        for _, enemy in ipairs(closestPlayers) do
            handleAnimations(enemy)
        end
    end
    
    -- Connect to Heartbeat for frame rate independence
    RunService.Heartbeat:Connect(parryLogic)
    
    warn("Enhanced Parry Script Executed")
    

    Key Enhancements Explained

    1. Advanced Predictive Algorithm:

      • predictPosition Function: Estimates the future position of an enemy based on their current velocity and a prediction time (e.g., 0.5 seconds ahead). This helps in anticipating enemy movements, making parrying more effective.
    2. Heartbeat Replacement:

      • RunService.Heartbeat: Replaces RenderStepped with Heartbeat to ensure that the parry logic runs independently of the frame rate, providing more consistent performance across different devices.
    3. Animation Detection and Tracking:

      • trackedAnimations Table: Expanded to include the specific dash animations you provided (Left Dash, Right Dash, Front Dash, Back Dash) with their respective rbxassetids. Each entry now includes a Type (e.g., dash, anim, ability) and a Range indicating the time window within the animation to trigger a parry.
      • handleAnimations Function: Checks if any of the tracked animations are currently playing within the specified time range. If so, it performs a parry and optionally adjusts the player's orientation towards the predicted position of the enemy.
    4. Optimizations and Improvements:

      • Debounce Mechanism: Prevents multiple parry attempts from happening simultaneously, ensuring that parries have cooldown periods (duration) as specified.
      • isPlayerFacing Function: Determines if the enemy is within the field of view (Fov) and facing towards the player to ensure that parries are contextually relevant.
      • Code Cleanup: Organized the animation tracking into a single table (trackedAnimations) for easier management and scalability.

    Additional Recommendations

    • Error Handling: Ensure that all necessary objects (like Communicate) exist to prevent runtime errors. You might want to add checks or error handling mechanisms.

      local communicate = plr.Character:FindFirstChild("Communicate")
      if communicate then
          communicate:FireServer({...})
      else
          warn("Communicate object not found!")
      end
      
    • Configuration Options: Consider exposing more settings to allow dynamic adjustments without modifying the script. For example, prediction time, debounce duration, etc., can be part of the Settings table.

    • Security and Fair Play: Be cautious when using or distributing scripts that manipulate game mechanics, as they can be against Roblox's Terms of Service and considered cheating in multiplayer environments. Always ensure that your scripts comply with Roblox's community guidelines and terms.

    Final Note

    This enhanced script aims to provide a more robust and efficient parrying system by incorporating predictive algorithms and ensuring frame rate independence. Make sure to test the script thoroughly in a controlled environment to fine-tune its behavior and ensure it interacts correctly with all game elements.