local F=""local q=nil local Z=nil local s=nil function toolKeyFrameReachedFunc(q)if q=="\069\110\100"then playToolAnimation(F,.0,Humanoid)end end function playToolAnimation(Q,N,t,T)local b=rollAnimation(Q)local h=animTable[Q][b].anim if Z~=h then if q~=nil then q:Stop()q:Destroy()N=0 end q=t:LoadAnimation(h)if T then q.Priority=T end q:Play(N)F=Q Z=h s=q.KeyframeReached:connect(toolKeyFrameReachedFunc)end end function stopToolAnimations()local Q=F if s~=nil then s:disconnect()end F=""Z=nil if q~=nil then q:Stop()q:Destroy()q=nil end return Q 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
