Tool hold animation not working

I created a custom tool holding animation that only augments both of the arms on an R15 rig. I put in this code:

(Clientside)

local backpack = LP:FindFirstChildOfClass("Backpack")
local toolEquipped = false

function initTools()
	for _, tool in pairs(backpack:GetChildren()) do
		tool.Equipped:Connect(function()
			toolEquipped = true
			COM.ToolSignal:FireServer("eq", tool.ToolId.Value)
		end)
		tool.Unequipped:Connect(function()
			toolEquipped = false
			COM.ToolSignal:FireServer("unq")
		end)
	end	
end
initTools()

backpack.ChildAdded:Connect(function()
	initTools()
end)

(Serverside)

toolSig = COM.ToolSignal

toolSig.OnServerEvent:Connect(function(plr, status, id)
	local track
	if status == "eq" then --equipped
		print("Tool Equipped. TID: ", id)
		local anim = Instance.new("Animation")
		anim.AnimationId = "http://www.roblox.com/Asset?ID=6162579234"
		
		track = plr.Character.Humanoid:LoadAnimation(anim)
		track.Priority = Enum.AnimationPriority.Action
		track.Looped = true
		track:Play()
	elseif status == "unq" and track ~= nil then
		track:Stop()
	end
end)

The purpose of my initTools function is to detect when the backpack changes and re-assess the player’s tools, allowing it to connect a function for each tool.

Here’s the problem:
It doesn’t work (as intended), quite simply.

I tried copying the Animation script from my character and commenting out this line:
playToolAnimation("toolnone", toolTransitionTime, Humanoid, Enum.AnimationPriority.Idle)

It seems to work until I take a step. Here is a GIF of me standing still, followed by some walking:
https://gyazo.com/e1651e43abb8f45ae84a4745312e5640

Additionally, in the output, the print statement is acting strangely. When I equip the tool, it prints “Tool Equipped. TID: pickaxe” once the first time, and when I unequip it it prints again. The second time I equip the tool, it prints twice, and when I unequip it again it prints once more. It keeps going like that but when I equip it again it prints one additional time. GIF of output for anyone confused:
https://gyazo.com/cb6e67d23425fe9d291b4510bc6cac05

Anyone know what’s wrong here?

1 Like

You can make it with Tool.Grip

It’s due to the fact that the script to keep the animation isn’t looping. Unless it loops, it’ll get canceled out by other animations taking priority over it.

(You could also loop the animation via the editor you used.)

I’d recommend just switching the toolnone animation in the Animate local script (I believe you can do that on the client).

I’m pretty sure that the Animate script stops other animations that it thinks shouldn’t be playing.

Interesting, I have looped set to true, and the Enum priority set to Action (which is the highest I believe)

Turns out the animation priority wasn’t set in the actual animation editor, only programmatically.