Animations not playing as expected

Hello, I have a combat system that has unexpected behavior thats happening as you can see in this video here.

Im pressig J to get a 4 hit combo, but when I do it the second time around the 3rd animation doesn’t play and skips to the 4th animation. It either does that or the 3rd animation will play super quick. I have a input buffer here in case the player presses the keys to fast to store them, heres the code:

	elseif actionName == "Attack" and inputState == Enum.UserInputState.Begin and tick() - LastM1 > .2 then
		startListening()
		LastM1 = tick()
		--Write to combat script and see who gets to go if player then return here and give player controls
		local AttackString = RecordInput(inputObject.KeyCode) -- fires the aniamtions
		print("Players current input is: ", AttackString)
		HandleInputs(AttackString)
		SubtractAp(inputObject.KeyCode)

I am using context action service for inputs, and the handle Inputs function looks like this:

local function HandleInputs(input)
	if not isPlaying then
		print("Handling input!")
		CombatModule.moveSet(input,player)
	elseif #queue < 4 then
		warn("Current Animation playing, adding,", input , " to queue: ",queue)
		table.insert(queue,input)
	else
		print("Queue is full!")
	end

end

and when the player presses J it goes to this table here and play the animations here:

	["J"] = {
		Action = function(Humanoid,newHitBox)
			local stoppedConnection
			New_Hit_Box:HitStart()
			preloaded_Animations["Med_M1"]:Play()
			IsPlaying:Fire(true)
			stoppedConnection = preloaded_Animations["Med_M1"].Stopped:Connect(function()
				stoppedConnection:Disconnect()
				
				IsPlaying:Fire(false)
				ProcessNextInputs:Fire()
				--Set a boolean to true and send it over when the first animation is finished
				--If IsPlaying is true then we queue the second input the player sends

			end)
			
			
			
			--preloaded_Animations["Med_M1"].Stopped:Wait()
				
			
			
			
			
			
			
			print("Medium M1")
		end,
	},

	["J_J"] = {
		Action = function(Humanoid,newHitBox)
			New_Hit_Box:HitStart()
			preloaded_Animations["Med_M2"]:Play()
			IsPlaying:Fire(true)
			preloaded_Animations["Med_M2"].Stopped:Connect(function()
				
				IsPlaying:Fire(false)
				ProcessNextInputs:Fire()
				--Set a boolean to true and send it over when the first animation is finished
				--If IsPlaying is true then we queue the second input the player sends

			end)
			
			print("Medium M2")
		end,
	},
	["J_J_J"] = {
		Action = function(Humanoid,newHitBox)
			local stoppedConnection
			New_Hit_Box:HitStart()
			preloaded_Animations["Med_M4"]:Play()
			IsPlaying:Fire(true)
			stoppedConnection = preloaded_Animations["Med_M4"].Stopped:Connect(function()
				stoppedConnection:Disconnect()
				
				IsPlaying:Fire(false)
				ProcessNextInputs:Fire()
				--Set a boolean to true and send it over when the first animation is finished
				--If IsPlaying is true then we queue the second input the player sends

			end)

			print("Medium M3")
		end,
	},
	["J_J_J_J"] = {
		Action = function(Humanoid,newHitBox)
			local stoppedConnection
			New_Hit_Box:HitStart()
			preloaded_Animations["Med_M3"]:Play()
			IsPlaying:Fire(true)
			stoppedConnection = preloaded_Animations["Med_M3"].Stopped:Connect(function()
				stoppedConnection:Disconnect()
				
				IsPlaying:Fire(false)
				--ProcessNextInputs:Fire()
				--Set a boolean to true and send it over when the first animation is finished
				--If IsPlaying is true then we queue the second input the player sends

			end)
			print("Medium M4")
		end,
	},

The first animation priority is set to action 1 and second animation is set to action 2 and so on.
So Im not sure why the third animation keeps getting skipped?
This module script here preloads all the animations I have.

local function PreloadComponents(player)
	local animator = player.Character.Humanoid:WaitForChild("Animator")
	
	--preLoadAnims
	print("Loading animations")
	for i, v in pairs(AnimFolder.Combat.KnifeAnims:GetChildren()) do
		contentProvider:PreloadAsync({v})
	end
	print("finished loading")
	
	preloaded_Animations["M1"] = animator:LoadAnimation(M1)	
	preloaded_Animations["M2"] = animator:LoadAnimation(M2)	
	preloaded_Animations["M3"] = animator:LoadAnimation(M3)	
	preloaded_Animations["M4"] = animator:LoadAnimation(M4)
	preloaded_Animations["SpecialAttack1"] = animator:LoadAnimation(SpecialAttack1)
	preloaded_Animations["Deathblow"] = animator:LoadAnimation(DeathBlow1)
	preloaded_Animations["Med_M1"] = animator:LoadAnimation(Med_M1)
	preloaded_Animations["Med_M2"] = animator:LoadAnimation(Med_M2)
	preloaded_Animations["Med_M3"] = animator:LoadAnimation(Med_M3)
	preloaded_Animations["Med_M4"] = animator:LoadAnimation(Med_M4)
	end

Can anyone help me please.

okay so i was missing the stopped connection in the table “J_J”, which was building up events constantly making animation “J_J_J_J” not play. I think it has something to do with this issue here that this topic mentioned here. Idk thats weird but everything is working!

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