Coin Pick Up Issue

I created a coin that has a particle effect and an add value to the score once you pick it up. I created a prefab of the coin and everytime I pick up the coin, all the other prefabs disappear but the score adds up for all the other coins. Any help?

CoinPickup.js

#pragma strict

var coinEffect : Transform;
var coinValue = 1;

function OnTriggerEnter (info : Collider)
{
    if (info.tag == "Player")
    {
        GameMaster.currentScore += coinValue;
        // Particle Effect on Trigger
        var effect = Instantiate(coinEffect, transform.position, transform.rotation);
        Destroy(effect.gameObject, 3);
        Destroy(gameObject);
    }
}

GameMaster.js

#pragma strict

static var currentScore : int = 0;
var offsetY : float = 40;
var sizeX : float = 100;
var sizeY : float = 40;

var musicPrefab : Transform;

function Start ()
{
    currentScore = 0;
   // Music on load plays non-stop ignoring death.
    if (!GameObject.FindGameObjectWithTag("MM"))
    {
        var mManager = Instantiate (musicPrefab, transform.position, Quaternion.identity);
        mManager.name = musicPrefab.name;
        DontDestroyOnLoad (mManager);
    }
}

function OnGUI ()
{
    GUI.Box (new Rect (Screen.width/2-sizeX/2, offsetY, sizeX, sizeY), "Score: " +currentScore);
}

P.S: I’m new to Unity and mostly new to coding, yet understand a few bits and bobs.
Thanks in advance!

Update: The prefab doesn’t appear in the game anymore, the first coin does, but the clone is invisible yet I get Score: 2 not 1 when I pick up the coin itself.

var coinEffect : Transform;
var coinValue = 1;
function OnTriggerEnter (info : Collider)
{
    if (info.tag == "Player")
    {
        GameMaster.currentScore += coinValue;
        // Particle Effect on Trigger
        var effect = Instantiate(coinEffect, transform.position, transform.rotation);
coinValue++;
        Destroy(effect.gameObject, 3);
        Destroy(gameObject);
    }
}

My fault I say the coinValue added to the score at the beginning of the function. Let me try something else.

Wait are you saying I should attempt that code? :slight_smile: