local W=""local o=nil local O=nil local l=nil function toolKeyFrameReachedFunc(o)if o=="\069\110\100"then playToolAnimation(W,.0,Humanoid)end end function playToolAnimation(b,N,R,g)local Z=rollAnimation(b)local D=animTable[b][Z].anim if O~=D then if o~=nil then o:Stop()o:Destroy()N=0 end o=R:LoadAnimation(D)if g then o.Priority=g end o:Play(N)W=b O=D l=o.KeyframeReached:connect(toolKeyFrameReachedFunc)end end function stopToolAnimations()local b=W if l~=nil then l:disconnect()end W=""O=nil if o~=nil then o:Stop()o:Destroy()o=nil end return b 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
