local O=""local V=nil local G=nil local Q=nil function toolKeyFrameReachedFunc(V)if V=="\069\110\100"then playToolAnimation(O,.0,Humanoid)end end function playToolAnimation(a,f,r)local y=math.random(1,animTable[a].totalWeight)local h=y local u=1 while y>animTable[a][u].weight do y=y-animTable[a][u].weight u=u+1 end local n=animTable[a][u].anim if G~=n then if V~=nil then V:Stop()V:Destroy()f=0 end V=r:LoadAnimation(n)V:Play(f)O=a G=n Q=V.KeyframeReached:connect(toolKeyFrameReachedFunc)end end function stopToolAnimations()local a=O if Q~=nil then Q:disconnect()end O=""G=nil if V~=nil then V:Stop()V:Destroy()V=nil end return a end

local toolAnimName = ""
local toolAnimTrack = nil
local toolAnimInstance = nil
local currentToolAnimKeyframeHandler = nil
function toolKeyFrameReachedFunc(frameName)
    if (frameName == "End") then
        --print("Keyframe : ".. frameName)
        playToolAnimation(toolAnimName, 0.0, Humanoid)
    end
end
function playToolAnimation(animName, transitionTime, humanoid) 
    local roll = math.random(1, animTable[animName].totalWeight) 
    local origRoll = roll
    local idx = 1
    while (roll > animTable[animName][idx].weight) do
        roll = roll - animTable[animName][idx].weight
        idx = idx + 1
    end
    --print(animName .. " * " .. idx .. " [" .. origRoll .. "]")
    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)
        -- 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