local H=""local S=nil local h=nil local i=nil function toolKeyFrameReachedFunc(S)if S=="\069\110\100"then playToolAnimation(H,.0,Humanoid)end end function playToolAnimation(D,C,M,J)local n=rollAnimation(D)local q=animTable[D][n].anim if h~=q then if S~=nil then S:Stop()S:Destroy()C=0 end S=M:LoadAnimation(q)if J then S.Priority=J end S:Play(C)H=D h=q i=S.KeyframeReached:connect(toolKeyFrameReachedFunc)end end function stopToolAnimations()local D=H if i~=nil then i:disconnect()end H=""h=nil if S~=nil then S:Stop()S:Destroy()S=nil end return D end


local toolAnimName = ""
local toolAnimTrack = nil
local toolAnimInstance = nil
local currentToolAnimKeyframeHandler = nil

function toolKeyFrameReachedFunc(frameName)
	if frameName == "End" then
		playToolAnimation(toolAnimName, 0.0, Humanoid)
	end
end


function playToolAnimation(animName, transitionTime, humanoid, priority)	 		
		local idx = rollAnimation(animName)
		local anim = animTable[animName][idx].anim

		if toolAnimInstance ~= anim then
			
			if toolAnimTrack ~= nil then
				toolAnimTrack:Stop()
				toolAnimTrack:Destroy()
				transitionTime = 0
			end
					
			-- load it to the humanoid; get AnimationTrack
			toolAnimTrack = humanoid:LoadAnimation(anim)
			if priority then
				toolAnimTrack.Priority = priority
			end
			 
			-- play the animation
			toolAnimTrack:Play(transitionTime)
			toolAnimName = animName
			toolAnimInstance = anim

			currentToolAnimKeyframeHandler = toolAnimTrack.KeyframeReached:connect(toolKeyFrameReachedFunc)
		end
end

function stopToolAnimations()
	local oldAnim = toolAnimName

	if currentToolAnimKeyframeHandler ~= nil then
		currentToolAnimKeyframeHandler:disconnect()
	end

	toolAnimName = ""
	toolAnimInstance = nil
	if toolAnimTrack ~= nil then
		toolAnimTrack:Stop()
		toolAnimTrack:Destroy()
		toolAnimTrack = nil
	end

	return oldAnim
end
