Why doesn't my parrying work?

You’ll have to be more specific.

After using my Parry, it seems like the combat is unable to be played and renders me only able to parry and block. There is no error included either.

You’re assuming I know how the rest of the combat works :slightly_smiling_face: There is likely a flag or value that’s not being reset though is my guess.

Oh, I’m sorry. I’ll show the local script of the combat, I feel and show a gif of the values.

Place1 - Roblox Studio (gyazo.com)

Place1 - Roblox Studio (gyazo.com)

Place1 - Roblox Studio (gyazo.com)

-- \\ Player-Related Variables //--

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HUM = Character:WaitForChild("Humanoid")



-- \\ Get-Service Variables // -- 

local UIS = game:GetService("UserInputService")

local RS = game:GetService("ReplicatedFirst")

-- \\ Server-Script-Variables // --

local SSS = game:GetService("ServerScriptService")

local RS = game:GetService("ReplicatedStorage")

local Combat101 = SSS:FindFirstChild("CombatHandler")

local CAS = game:GetService("ContextActionService")

-- \\ Cooldowns // --

local Debounce = false


local CDS = {

	1,
	2

}

-- \\ Anims Variables // --

local Animations = script.Animations

local Anims = {

	Animations.MeleeAnim1,
	Animations.MeleeAnim2,
	Animations.MeleeAnim3,
	Animations.MeleeAnim4,
}

local LoadedAnims = {

	Character.Humanoid:LoadAnimation(Anims[1]),
	Character.Humanoid:LoadAnimation(Anims[2]),
	Character.Humanoid:LoadAnimation(Anims[3]),
	Character.Humanoid:LoadAnimation(Anims[4]),

}

-- \\ Misc. Variables // --

local Count = 0

local SwingDelay = 0.5

local AirKickEnabled = false

local AerialDebounce = false

-- \\ Functions // --

HUM.StateChanged:Connect(function(oldState, newState)
	if newState == Enum.HumanoidStateType.Jumping then
		if not AirKickEnabled and AerialDebounce then
			wait(.02)
			if HUM:GetState() == Enum.HumanoidStateType.Freefall then
				
				AirKickEnabled = true 
				AerialDebounce = true
				task.wait(15)
				AirKickEnabled = false
				AerialDebounce = false
			elseif HUM:GetState() == Enum.HumanoidStateType.Landed then
				AirKickEnabled = false
				task.wait(30)
				
			
			end
		end
	end
end)


UIS.InputBegan:Connect(function(Input, Processed)

	if Processed then
		return
	end
	
	

	if Input.UserInputType == Enum.UserInputType.MouseButton1 then

		if Debounce == true then return end


		if Count == 4 then
			Count = 1
			print("reset combo")
		else
			Count += 1
			print("add to combo")
		end



		Debounce = true

		LoadedAnims[Count]:Play()

		RS.Combat:FireServer(Count)
		
		print("It work")
		delay(SwingDelay, function()
			Debounce = false
		end)

		
	end
end)

I see, so you also utilize the MouseButton1 for attacking. If you did not unbind the parry action from MouseButton1 then it may be blocking your attack function here. I’m not certain but its probably being marked as “processed”. That’s why i said before you should make the key bind when blocking starts. Then unbind the action/key after the parry is complete.

You could probably bind/unbind actions for all of this just using the ContextActionService. That would make it easier to utilize different control devices as well.

This attack function using CAS:

local attacking = false
local attackCount = 1
local function Attack(actionName, inputState, inputObj)
	
	if(actionName == "Attack" and inputState == Enum.UserInputState.Begin)then
		if(attacking)then return end --already attacking, exit
		attacking = true --attacking
		
		--Change attack anim based on count
		if(attackCount == 4)then
			attackCount = 1
		else
			attackCount += 1
		end
		
		LoadedAnims[Count]:Play()
		RS.Combat:FireServer(Count)
		LoadedAnims.Stopped:Wait() --Wait for the anim to end
		task.wait(SwingDelay) --delay between swings
		attacking = false --Can attack again
	end
end
--You can leave this bound, when you bind another action, this will be temp disabled in favor of the new bind (for parry)
--When Parry action is unbound, this action should be active again.
game:GetService("ContextActionService"):BindAction("Attack", Attack, false, Enum.UserInputType.MouseButton1)
1 Like