Can't get this right, someone help me please

BCE0048 : Type ‘UnityEngine.GameObject’ does not support slicing.

Hi everybody, this error appeared when i added an script, and i dont know what to do.

The error:

BCE0048 : Type ‘UnityEngine.GameObject’ does not support slicing.

Means your taking an object that is not an array/list/collection and trying to treat it as one. If animation is NOT an array or contain an indexer, then you can not do that. Also your posted image for your source doesn’t help whatsoever since it’s doesn’t:

  1. Actually post the entire error form the console
  2. Point to the line where the issue is occurring
  3. Include the definition of the object in question… is what you posted relavent to the splicing error? Is ‘animation’ just a type of GameObject?

Either way, don’t treat a GameObject like an array.