Play animation only once?

So I’m still very new to animating in unity so far but I have an animation for a popup text so that it will rise onto the screen for a few seconds then go back under the UI, but this should only happen each time something is picked up. The closest I’ve gotten this to working is that the animation is constantly playing. The main error I keep getting is that there is no function name specified? This is the code that i’m using to play the animation when selected:



change your system to use a animator rather than just animation. Second, set up a animation of your pop up in action, than of your pop up in an idle state. Lastly set up your animator to use a trigger, when activated, play pop up animation, after that switch back to idle.
To activate the new animator, use the code Animator example.SetTrigger("Pop up");