Animation breaking when spammed please help!

Hi so I have an emote system when I spam animations while walking/running This bug happens:

this is my second post on this topic, no one helped me on the first one

https://gyazo.com/e6741cdb5ea08d5c9c61d0831c8100eb

Heres the scripts:

local function ClearAnimationTracks(Humanoid)
	for i,v in pairs(Humanoid:GetPlayingAnimationTracks()) do
		print(v)
		while v.IsPlaying do -- will always stop the animation, no matter what.
			v:Stop()
			v:Destroy()
		end
	end
end

local function LoadAnimation(AnimationId,looped)

	local Character = Player.Character

	local Humanoid = Character:WaitForChild("Humanoid")
	
	ClearAnimationTracks(Humanoid)
	
	
	if animdebounce == false then
		animdebounce = true 

	Animator = Humanoid:WaitForChild("Animator")
	Animation = Instance.new("Animation")
		Animation.AnimationId = AnimationId
		
		print(AnimationId)

	AnimationTrack2 = Animator:LoadAnimation(Animation)

	AnimationTrack2.Priority = Enum.AnimationPriority.Action
	
	
		AnimationTrack2:Play()
		
		AnimationTrack2.Stopped:Connect(function()
			AnimationTrack2:Destroy()
		end)
	
	
	Humanoid.Running:Connect(function(speed)
		
		if speed >= 0.0001 then
			
			if AnimationTrack2 then
				AnimationTrack2:Stop()
				AnimationTrack2 = nil
			end
					
			
			
		end
		end)
		
		AnimationTrack2.Stopped:Connect(function()
			animdebounce = false
		end)
	end
end

Try adding a wait(0.5) between changing the debounces value.

Just tried, unfortunately still happening.

Interesting, what is breaking when you spam it?

Did u watch the video?? it shows it in there

Add a wait between the debounces that are slightly longer than the animation time.

You can use something like this


local db = false

if not db then
		db = true
		track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
		track.Priority = Enum.AnimationPriority.Action
		track.Looped = false
		track:Play()
		wait(6)
		db = false

	end

This did not work. still not sure whats happening

Hmmm thats odd because I tested it in mine and mine worked. Maybe you misplaced the code.