Pastebin
Paste #49718: No description
< previous paste - next paste>
Pasted by Anonymous Coward
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local LocalPlayer = Players.LocalPlayer
local Character
local HumanoidRootPart
-- Cooldown to prevent spamming the parry
local parryCooldown = 0.5 -- Time between each parry action (in seconds)
local lastParryTime = 0
-- Initialize character and HumanoidRootPart
local function initializeCharacter()
Character = LocalPlayer.Character
if not Character then
Character = LocalPlayer.CharacterAdded:Wait()
end
HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
end
initializeCharacter()
-- Handle when the character is added/re-spawned
LocalPlayer.CharacterAdded:Connect(function(newChar)
Character = newChar
HumanoidRootPart = newChar:WaitForChild("HumanoidRootPart")
end)
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 shouldParry = false
local myPos = HumanoidRootPart.Position
local parryDistance = 13.5 -- Distance to check for enemies
-- Look for nearby enemies and check if they are holding a parry-able tool
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 player is holding a tool that can be parried
for _, item in ipairs(targetChar:GetChildren()) do
if item:IsA("Tool") and item:GetAttribute("Parry") then
shouldParry = true
break
end
end
end
end
if shouldParry then
break
end
end
if shouldParry then
-- Perform the parry action without animation or visual effects
-- Example: Deal damage to the attacking player, block the attack, or apply any effect
-- If you want to trigger something here (like a sound, a special effect, or a damage block), you can add it.
-- Update the last parry time to handle cooldown
lastParryTime = tick()
end
end)
print("Parry mechanic activated without animation.")
New Paste
Go to most recent paste.