Changing frames depending on variables

I want to learn how to change frames of a weapon depending on different variables. Like if sword==true then it would go to a frame called “sword” I can’t really figure this one out, so if anyone knows how I can do then thanks ^^