Cannot figure out how to trigger an animation when a gear is used

I’m trying to figure out how to trigger an animation for the player if they click while holding a gear. All my attempts at this have failed as well as trying to find stuff online to put into my code. If you could give me a sample of a code block I could use in order to make this work I would appreciate it.

image_2022-08-14_161330869

local tool = script.Parent

local char = nil

local animid = 10589014662 -- replace with ur animation id

tool.Equipped:Connect(function()
	char = script.Parent.Parent
end)
tool.Unequipped:Connect(function()
	char = nil
end)

function LoadAnim(Hum, id)
	local anim = Instance.new("Animation")
	anim.AnimationId = "rbxassetid://"..tostring(id)
	local loaded_anim = Hum:FindFirstChild("Animator"):LoadAnimation(anim)

	return loaded_anim
end


tool.Activated:Connect(function()
	if not char then return; end
	local humanoid = char:FindFirstChild("Humanoid")
	if not humanoid then return; end
	
	local anim = LoadAnim(humanoid, animid)
	anim:Play()

end)