Animation gets stuck on click, help needed

  1. What do you want to achieve? I want the block Animation to not get stuck

  2. What is the issue? The animation gets stuck if i click while blocking with custom

  3. What solutions have you tried so far? I tried using passive dectors

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local blockAnim2
local ValidToolEquipped
game:GetService("UserInputService").InputBegan:Connect(function(Keyinput)
	ValidToolEquipped = false
	for i, v in pairs(Character:GetChildren()) do
		if v.ClassName == "Tool" and v:FindFirstChild("BlockAnim") then
			blockAnim2 = human:LoadAnimation(v.BlockAnim)
			ValidToolEquipped = true
		end
	end
	
	local stunned = Character:FindFirstChild("Stunned")
	if stunned then return end
	
	if Keyinput.KeyCode == Enum.KeyCode.F then
		if debouncenumber1 == true then
			debouncenumber1 = false
			print("PerfBlok")
			script.BlockEvent:FireServer(true)
		else
			print("Blok")
			script.BlockEvent:FireServer(false)
		end
		if ValidToolEquipped ~= true then
			blockAnim:Play()
		else
			blockAnim2:Play()
		end
		wait(1)
		debouncenumber1 = true
	end
end)

game:GetService("UserInputService").InputEnded:Connect(function(Keyinput, chatting)
	if Keyinput.KeyCode == Enum.KeyCode.F or chatting then
		print(ValidToolEquipped)
		print("Unblocking")
		script.UnblockEvent:FireServer()
		wait()
		if ValidToolEquipped ~= true then
			blockAnim:Stop()
		else
			blockAnim2:Stop()
		end
	end
end)

local CheckForBlock = function()
	wait(0.2)
	local humanoid = human
	local checkifblocking = human:FindFirstChild("IsBlocking")
	local holdingF = game:GetService("UserInputService"):IsKeyDown(Enum.KeyCode.F)
	
	if checkifblocking and holdingF then
		print("Still here")
	else
		for _, playingTracks in pairs(humanoid:GetPlayingAnimationTracks()) do
			playingTracks:Stop(0)
		end
	end
end

Do you ever run CheckForBlock? I think the issue is it’s not checking if they unblocked.

It did work, but now its doing a weird thing where it keeps looping checkforblock, so i cant even use m1 attack

oh wait, i just realized i put the function right after inputbegan

Edit: Still doesnt work