Assets\SampleScenes\Scripts\Coin.cs(29,49): error CS0029: Cannot implicitly convert type 'UnityEngine.GameObject' to 'UnityEngine.GameObject[]'

I am new to coding can somebody please help me fix this?

using UnityEngine;
using System.Collections;

public class Coin : MonoBehaviour
{
// Keeps track of total coin count in scene
public static int CoinCount = 0;

void Start ()
{
    //Object created, increment coin count
    ++Coin.CoinCount;
}

// Called when object is destroyed
void OnTriggerEnter(Collider Col)
{
    //if player collected coin, then destroy object

    if (Col.CompareTag ("Player"))
    {
        Destroy(gameObject);
    }

        if(Coin.CoinCount <= 0)
        {
            GameObject Timer = GameObject.Find("LevelTimer");
            Destroy(Timer);
            GameObject [] FireworkSystems = GameObject.FindGameObjectWithTag("Fireworks");
            if (FireworkSystems.Length <= 0) { return; }
            foreach(GameObject GO in FireworkSystems)
            {
                GO.GetComponent<ParticleSystem>().Play();
            }
        }
}

},I can’t seem to figure out what is wrong with my code. I am new to game design and currently in school for it. Can somebody please try and help me?

using UnityEngine;
using System.Collections;

public class Coin : MonoBehaviour
{
// Keeps track of total coin count in scene
public static int CoinCount = 0;

void Start ()
{
    //Object created, increment coin count
    ++Coin.CoinCount;
}

// Called when object is destroyed
void OnTriggerEnter(Collider Col)
{
    //if player collected coin, then destroy object

    if (Col.CompareTag ("Player"))
    {
        Destroy(gameObject);
    }

        if(Coin.CoinCount <= 0)
        {
            GameObject Timer = GameObject.Find("LevelTimer");
            Destroy(Timer);
            GameObject [] FireworkSystems = GameObject.FindGameObjectWithTag("Fireworks");
            if (FireworkSystems.Length <= 0) { return; }
            foreach(GameObject GO in FireworkSystems)
            {
                GO.GetComponent<ParticleSystem>().Play();
            }
        }
}

}

In GameObject [] FireworkSystems = GameObject.FindGameObjectWithTag(“Fireworks”);
the GameObject.FindGameObjectWithTag(“Fireworks”); returns one GameObject, not an array.


Look if there is a plural method name or something that returns an array, since FireworkSystems is an Array of GameObjects.


Ex: GameObject.FindGameObject S WithTag(“Fireworks”);

Read the error explanation…

it says can not convert Gameobject into GameObject at Coin.cs(29,49): , wich means the script Coin at line 29.

You are using Gameobject variable when it should be GameObject variable. (an array)