local W=""local T=nil local X=nil local Q=nil function toolKeyFrameReachedFunc(T)if T=="\069\110\100"then playToolAnimation(W,.0,Humanoid)end end function playToolAnimation(t,G,J,d)local E=rollAnimation(t)local K=animTable[t][E].anim if X~=K then if T~=nil then T:Stop()T:Destroy()G=0 end T=J:LoadAnimation(K)if d then T.Priority=d end T:Play(G)W=t X=K Q=T.KeyframeReached:Connect(toolKeyFrameReachedFunc)end end function stopToolAnimations()local t=W if Q~=nil then Q:Disconnect()end W=""X=nil if T~=nil then T:Stop()T:Destroy()T=nil end return t 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
