Animation not stopping when doing animationTrack:Stop()

Recently I have made a system where you can buy different dances in the game, before this, the button to stop and start dancing was working fine, however now when I have adjusted the code to work with multiple dances, it doesn’t stop the animation.

Code
local ContentProvider = game:GetService("ContentProvider")

local emoteButton = script.Parent

local player = game.Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
	character = player.CharacterAdded:wait()
end
local humanoid = character:WaitForChild("Humanoid")

local dances = character:WaitForChild("Dances")
local equipped = dances:WaitForChild("Equipped")



local animation = Instance.new("Animation")



local playing = false



emoteButton.MouseButton1Up:Connect(function()	
	local dance = equipped:FindFirstChildWhichIsA("Folder")
	if dance then
		animation.AnimationId = dance:WaitForChild("animationId").Value

		ContentProvider:PreloadAsync({animation})
		local animationTrack = humanoid:LoadAnimation(animation)

		if playing == false then
			playing = true
			animationTrack:Play()
		else
			playing = false
			animationTrack:Stop()

		end
	end
end)

Although it’s doing the animationTrack:Stop() function, it only resets the dance back to the beginning and then starts playing again, would anyone know how to fix this?

Found a way to fix it by doing:

			local AnimationTracks = humanoid:GetPlayingAnimationTracks()
			for i, v in pairs(AnimationTracks) do
				v:Stop()
			end