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