Pastebin

Paste #49702: No description

< previous paste - next paste>

Pasted by Anonymous Coward

Download View as text

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local VirtualInputManager = game:GetService("VirtualInputManager")
local LocalPlayer = Players.LocalPlayer

-- Configuration
local CONFIG = {
    PARRY_COOLDOWN = 0.4,  -- seconds between parries
    PARRY_DISTANCE = 13.8, -- detection range
    HOLD_DURATION = 0.1,   -- how long to hold parry
    WHITELIST_TOOLS = true -- only parry whitelisted tools
}

-- Whitelist of dangerous tools (add more as needed)
local DANGEROUS_TOOLS = {
    ["Katana"] = true,
    ["Greatsword"] = true,
    ["Dagger"] = true,
    ["Nodachi"] = true
}

-- State variables
local Character, HumanoidRootPart
local lastParryTime = 0
local isParrying = false

-- Improved character initialization
local function initializeCharacter()
    local char = LocalPlayer.Character
    if not char then
        char = LocalPlayer.CharacterAdded:Wait()
    end
    Character = char
    HumanoidRootPart = char:WaitForChild("HumanoidRootPart")
end

-- Better enemy detection
local function getNearbyEnemies()
    if not HumanoidRootPart then return {} end
    
    local myPos = HumanoidRootPart.Position
    local nearby = {}
    
    for _, player in ipairs(Players:GetPlayers()) do
        if player ~= LocalPlayer and player.Character then
            local targetHRP = player.Character:FindFirstChild("HumanoidRootPart")
            if targetHRP and (myPos - targetHRP.Position).Magnitude <= CONFIG.PARRY_DISTANCE then
                table.insert(nearby, {
                    Player = player,
                    Character = player.Character,
                    Distance = (myPos - targetHRP.Position).Magnitude
                })
            end
        end
    end
    
    -- Sort by distance (closest first)
    table.sort(nearby, function(a, b) return a.Distance < b.Distance end)
    return nearby
end

-- Check if enemy is attacking
local function isEnemyAttacking(enemy)
    if not enemy.Character then return false end
    
    -- Check for tool with Parry attribute
    for _, item in ipairs(enemy.Character:GetChildren()) do
        if item:IsA("Tool") then
            if CONFIG.WHITELIST_TOOLS then
                if DANGEROUS_TOOLS[item.Name] then return true end
            else
                if item:GetAttribute("Parry") then return true end
            end
        end
    end
    
    -- Additional attack detection (game-specific)
    local humanoid = enemy.Character:FindFirstChildOfClass("Humanoid")
    if humanoid and humanoid:GetState() == Enum.HumanoidStateType.Running then
        return true -- Many games use running state for attacks
    end
    
    return false
end

-- Optimized parry function
local function parry()
    if isParrying or (tick() - lastParryTime) < CONFIG.PARRY_COOLDOWN then
        return
    end
    
    isParrying = true
    lastParryTime = tick()
    
    VirtualInputManager:SendMouseButtonEvent(0, 0, 1, true, game, 1)
    task.wait(CONFIG.HOLD_DURATION)
    VirtualInputManager:SendMouseButtonEvent(0, 0, 1, false, game, 1)
    
    isParrying = false
end

-- Main loop
RunService.Heartbeat:Connect(function()
    if not Character or not Character.Parent then
        initializeCharacter()
        return
    end
    
    local nearbyEnemies = getNearbyEnemies()
    for _, enemy in ipairs(nearbyEnemies) do
        if isEnemyAttacking(enemy) then
            parry()
            break
        end
    end
end)

-- Initialize
initializeCharacter()
LocalPlayer.CharacterAdded:Connect(initializeCharacter)

print("Enhanced Auto Parry loaded.")

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.