Animation Script

Hi Unity Community! Im trying to setup a script so that my character’s animations will play whenever I hold down a key and then release it. I had some errors so I checked the documentation and I corrected them but inside Unity it says “The best overloaded method for ‘UnityEngine.Animation.Play(UnityEngine.PlayMode’) has some invalid arguments”

Can anyone please explain what’s wrong and explain what does it mean? Thank you!!

using UnityEngine;
using System.Collections;

public class AnimAedan : MonoBehaviour {
	
	public Animation AedanIdle;
	public Animation AedanRunning;
	public Animation AedanAttack1;
	public Animation AedanAttack2;
	public Animation AedanAttack3;
	public Animation AedanAttack4;
	
	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
		if (Input.GetKeyDown(KeyCode.LeftArrow))

	{
			animation.Play(AedanRunning);
	}
		
		if (Input.GetKeyUp(KeyCode.LeftArrow))

	{
			animation.Play(AedanIdle); 
	}
		
		if (Input.GetKeyDown(KeyCode.RightArrow))
	{
			animation.Play(AedanRunning); 
	}
	
		if (Input.GetKeyUp(KeyCode.RightArrow))

	{
			animation.Play(AedanIdle); 
	}
		
		if (Input.GetKeyDown(KeyCode.UpArrow))
	{
			animation.Play(AedanRunning); 
	}
	
		if (Input.GetKeyUp(KeyCode.UpArrow))

	{
			animation.Play(AedanIdle); 
	}
		
		if (Input.GetKeyDown(KeyCode.DownArrow))
	{
			animation.Play(AedanRunning); 
	}
		
		if (Input.GetKeyUp(KeyCode.DownArrow))

	{
			animation.Play(AedanIdle); 
	}
		
	}
}

Hi the mistake is you are trying to assign animation componenet it self to play the animation (it would be like animation.Play(animation.);)you cant do that, SO you can only assign animation clps

Change from

 public Animation AedanRunning;
public Animation AedanAttack1;
public Animation AedanAttack2;
public Animation AedanAttack3;
public Animation AedanAttack4;

 void Update () {
 
if (Input.GetKeyDown(KeyCode.LeftArrow))
 
{
animation.Play(AedanRunning);
}
 
if (Input.GetKeyUp(KeyCode.LeftArrow))
 
{
animation.Play(AedanIdle);
}
<..etc..>

To:

public AnimationClip AedanRunning;
public AnimationClip AedanAttack1;
public AnimationClip AedanAttack2;
public AnimationClip AedanAttack3;
public AnimationClip AedanAttack4;
void Update () {

if (Input.GetKeyDown(KeyCode.LeftArrow))

{
animation.Play(AedanRunning.name);//Only string can be assgin for animation .play
}

if (Input.GetKeyUp(KeyCode.LeftArrow))

{
animation.Play(AedanIdle.name);
}

//change for the rest of codes