Using animations from variables in Anim BP?

Many ways do it.

Create a Data table called Weapon DB. This will have all the details regarding the weapon, such as bullet speed, bullet damage, Idle animation etc.

Create a function called SetCurrentIdleAnim in your animation blueprint.

When you call your switch weapon function, grab the animation associated along with the weapon (From the data table) and pass it to SetCurrentIdleAnim.

By doing this, you send the current idle animation everytime you switch the weapon instead of polling it in a tick function.

Hope this helps.