How to let a animation finish its loop

Hi all,

I have this script that plays an animation on a tool whenever i press the mousebutton. However when you spam the mousebutton key, the animation will not finish but is spamming aswell. Is there a way to prevent the animation spamming? So the animation first finish its loop and than start again if the mousebutton is pressed?

local Tool = script.Parent
local Animation = Tool.Dig

	local Character = Tool.Parent
	local Humanoid = Character.Humanoid

	local AnimationTrack = Humanoid:LoadAnimation(Animation)
	Humanoid.WalkSpeed = 0
	Humanoid.WalkSpeed = 16
	-- proceed

i use Animator:GetPlayingAnimationTracks() to see which ones are playing. It returns a table so you can ask if the current animation is part of the PlayingTracks table

I found a solution by adding in this:

	script.Disabled = true
	wait (2) --time it takes for the animation
	script.Disabled = false

thank you for your reply :slight_smile: