Change animation speed in randomly generated objects

Hi there.

I’m currently devoloping this little project and I was wondering how can I change the animation speed of several instances of a prefab.

Let me explain a little bit better.In this game the basic concept is that pieces appear in random positions of the screen and they can be from 4 possible types (red,green,blue,yellow) and i would like for when they spawn, each piece as its own animation speed(a random one,of course it can be repeated).

I dunno if I made myself clear but it’s my first time posting here my questions.

Thank you for your time and have a nice day.

If are you using animator, you can use:

newGameObject.GetComponent<Animator>().speed = Random.Range(minSpeed, MaxSpeed);

Where speed, affect all speed animations in the Animator.