I have a script which makes you do an idle animation when holding the tool.

local tool = script.Parent
local animtrack
repeat wait() until game.Players:GetPlayerFromCharacter(tool.Parent)
local plr = game.Players:GetPlayerFromCharacter(tool.Parent)

tool.Equipped:Connect(function()
    local anim = game.ReplicatedStorage:FindFirstChild("Idle")
    animtrack = plr.Character.Humanoid:LoadAnimation(anim)
    animtrack:Play()
end)

tool.Unequipped:Connect(function()
    local AnimationTracks = game.Players.LocalPlayer.Character.Humanoid:GetPlayingAnimationTracks()
    animtrack:Stop()
    for i, track in pairs (AnimationTracks) do
        track:Stop()
    end
end)

However, whenever I unequip the tool, it doesn't stop the animation. Instead I am frozen in the pose that the animation played when I equiped the wand.

Does anyone know how to fix it: how to set the animation back to the idle one?