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