Changing animation speed

So I have a game object with the animation component attached, with one animation file. Everything runs smoothly. Now I want to change the speed of the animation, which I am having trouble with.
The animation is marked as legacy. Here is my code:

var animSpeed:Animation;

animSpeed = GetComponent.();

animSpeed.speed = 5 //for instance

I have also tried something like this:

animation[“animation_name”].speed = something;

What am I doing wrong?

Have you tried setting the animation speed to a value between 0 and 1? From my understanding, setting the speed to 0.5f would play the animation at half speed.

animation["Animation name"].speed = 0.5f;

Still no luck. I keep getting the error:
Type ‘UnityEngine.Component’ does not support slicing.

does this solve things?

If so, remember to google your errors :wink:

Yes, that solved it! Thanks!