Animation ["1"].speed = 0; Doesn't work

Hi, I was trying to start an animation stopped and play it when I press a button, so far I got this:

using UnityEngine;
using System.Collections;

public class animatorcotrols : MonoBehaviour {
	
	void Sart() 
	{
		Animation ["1"].speed = 0;
	}

	void OnGUI()
	{
		if(GUI.Button(new Rect(0, 0, 100, 100), "Debug!"))
		{
			Animation ["1"].speed = 1;
		}
	}

}

But it says

Assets/animatorcotrols.cs(8,17): error CS0119: Expression denotes a type', where a variable’, value' or method group’ was expected

I don’t know if I should use this function or is there a better way to do this, I’ve searched everywhere and I can’t find the solution, the worst part is that I’ve done this before and it’s extremely simple but I just can’t, thanks for your help in advance.

You have to reference a specific animation clip:

Animation animation = GetComponent<Animation>();
string animationClipName = "1";

animation[animationClipName].speed = 0;

Of course, this means that you will only see the result when you actually play the clip.

Animation is a class and you are trying to use it like an object. If you want to access the Animation connected to a unity object you have to do it like this:

Animation animation = GetComponent<Animation>();
animation.speed = 1;

I am not sure if this still works though. I didn’t work with the Animation class for years. You should have a look at the tutorials: