Stop an animation from plaiyng if another one is

i have a animation that starts when K is pressed the problem is that every time i press the key the animation starts but i want it to play until is finished and when it is finished be able to play it again

local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()



local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=6968729568"

mouse.KeyDown:connect(function(key)
	if key == "z" then
		local playAnim = humanoid:LoadAnimation(anim)
		playAnim:Play()

	end
end)
1 Like

if anyone needs it this works

 local player = game.Players.LocalPlayer
repeat wait() until player.Character.Humanoid
local humanoid = player.Character.Humanoid
local mouse = player:GetMouse()
local debounce = false


local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/asset/?id=6968729568"

mouse.KeyDown:connect(function(key)
	if key == "z" then
		if debounce == false then
		local playAnim = humanoid:LoadAnimation(anim)
		playAnim:Play()
		if playAnim.IsPlaying then
				debounce = true
				wait(1)
				debounce = false
			end
		end

	end
end)

thank you very very much! you saved my life