Parry System Doesnt Work

Hello, so i got this script (a parry script) which detects if a part called a “Blade” hits a part named “ParryPart” then the player who hit the ParryPart gets their Humanoidrootpart anchored, tools unequipped, and their backpack disabled for 3 seconds.

local tool = script.Parent
local CanDamage = true
local CanBeParried = false
local soundTable = game.ReplicatedStorage.Sounds:GetChildren()
local sound = soundTable[math.random(1, #soundTable)]
		local player = script:FindFirstAncestorWhichIsA"Player" or game:GetService"Players":GetPlayerFromCharacter(script.Parent.Parent)
			if Hit.Name == "ParryPart" then
				CanBeParried = true
				if CanBeParried == true then
					local StarterGui = game:GetService("StarterGui")
					StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
					player.Character:FindFirstChild("HumanoidRootPart").Anchored = true
					tool:FindFirstChild("ParryHandler").Enabled = false
					CanBeParried = false
					CanBeParried = true
					local StarterGui = game:GetService("StarterGui")
					player.Character:FindFirstChild("HumanoidRootPart").Anchored = false
					StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
					tool:FindFirstChild("ParryHandler").Enabled = true

but when i just click and then after a few seconds touch the ParryPart with my sword, i get anchored, but i want it to only happen when i touch it, please help.

Your code seems to make it so that whenever the Blade part touches the ParryPart, it triggers the parry system logic. You need to make sure that, the parry system only works when the player is playing the attack animation.

For instance, when the player clicks a key to attack or swing the Blade, use a variable to store a state which tells the server that the player is currently attacking because they are playing the attacking animation. Then, when the animation starts playing, connect the tool.Activated event at the same time, and disconnect it when the animation is done playing.

i’m trying to do that but i just keep getting lost, idk which varbiable do i set to false, which to true, and when do i change their value. its just confusing

i got no idea, nothing works for me.

Alright, i actually found a fix, i basically make a new variable called click, when i activate the weapon, the variable is true for 0.5 seconds and then its set to false, the script checks if the variable is true, if it is then it does the parry logic

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.