How to make a TextureRect appear with an animation and stay as long as I'm holding down a button?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 99week

I animated a TextureRect (black square) which comes from below the screen and disappears the same way (in AnimationPlayer: the TextureRect goes from one position to another). I want it so when holding a button (ex.: RMB) the animation plays and the TextureRect appears (comes up from below the screen via AnimationPlayer) and stays there as long as I’m holding down the button. And when I release the button, the TextureRect disappears with the corresponding animation (goes back, down below the screen via AnimationPlayer).

So far, I used this code so the TextureRect just appears and disappears but now I need it to do the same with animation.

	if Input.is_action_pressed("aim"):
	$black_box.visible = true
	$black_box.visible = false
:bust_in_silhouette: Reply From: Wakatta
if Input.is_action_just_pressed("aim"):
    $black_box.visible = true
elif Input.is_action_just_released("aim"):
    $black_box.visible = false

With "slide" being the name of your animation