local N=""local p=nil local f=nil local z=nil function toolKeyFrameReachedFunc(p)if p=="\069\110\100"then playToolAnimation(N,.0,Humanoid)end end function playToolAnimation(D,y,H,d)local x=rollAnimation(D)local E=animTable[D][x].anim if f~=E then if p~=nil then p:Stop()p:Destroy()y=0 end p=H:LoadAnimation(E)if d then p.Priority=d end p:Play(y)N=D f=E z=p.KeyframeReached:connect(toolKeyFrameReachedFunc)end end function stopToolAnimations()local D=N if z~=nil then z:disconnect()end N=""f=nil if p~=nil then p:Stop()p:Destroy()p=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
