local Players = game:GetService("Players") local RunService = game:GetService("RunService") local VirtualInputManager = game:GetService("VirtualInputManager") local LocalPlayer = Players.LocalPlayer local Character local HumanoidRootPart -- Cooldown to prevent spamming the parry local parryCooldown = 1 -- Adjust cooldown time as needed (in seconds) local lastParryTime = 0 -- Distance for parrying (i.e., how close an enemy must be to trigger a parry) local parryDistance = 13.5 local function initializeCharacter() Character = LocalPlayer.Character if not Character then Character = LocalPlayer.CharacterAdded:Wait() end HumanoidRootPart = Character:WaitForChild("HumanoidRootPart") end initializeCharacter() LocalPlayer.CharacterAdded:Connect(function(newChar) Character = newChar HumanoidRootPart = newChar:WaitForChild("HumanoidRootPart") end) -- Check for enemies in range and attempt to parry if they are holding a tool with "Parry" attribute RunService.Heartbeat:Connect(function() if not Character or not Character.Parent then initializeCharacter() return end -- Check cooldown before doing anything if (tick() - lastParryTime) < parryCooldown then return end local myPos = HumanoidRootPart.Position local shouldParry = false for _, player in ipairs(Players:GetPlayers()) do if player ~= LocalPlayer and player.Character then local targetChar = player.Character local targetHRP = targetChar:FindFirstChild("HumanoidRootPart") if targetHRP and (myPos - targetHRP.Position).Magnitude <= parryDistance then -- Check if the enemy player is holding a tool with "Parry" attribute for _, item in ipairs(targetChar:GetChildren()) do if item:IsA("Tool") and item:GetAttribute("Parry") then -- If they have a tool with "Parry" attribute, attempt to parry shouldParry = true break end end end end if shouldParry then break end end if shouldParry then -- Simulate a right-click (commonly used for block/parry) VirtualInputManager:SendMouseButtonEvent(0, 0, 1, true, game, 1) task.wait(0.5) -- Hold the button briefly VirtualInputManager:SendMouseButtonEvent(0, 0, 1, false, game, 1) -- Update the last parry time lastParryTime = tick() end end) -- Listen for when players start swinging their tools (for parry detection) for _, player in ipairs(Players:GetPlayers()) do if player ~= LocalPlayer then player.CharacterAdded:Connect(function(character) character:WaitForChild("Humanoid") -- Detect when the player uses a tool (e.g., swinging a weapon) for _, item in ipairs(character:GetChildren()) do if item:IsA("Tool") and item:GetAttribute("Parry") then item.Activated:Connect(function() -- We don't need to track each swing actively, because the parry will trigger automatically when in range end) end end end) end end) print("Auto-Parry script loaded.")