how can assign a gameObject from code using c#
<p>I'm working on random coin generator. I have included the code below: </p>

<pre><code>timer -= Time.deltaTime;

if (timer &lt;= 0)
{

    Vector3 position = new Vector3(Random.Range(11f, 14f), Random.Range(-0.7f, 4.5f), 0);
    Instantiate(coins, position, transform.rotation);
    timer = delayTimer;
}
</code></pre>

<p>and I add a collision to pick the coin and make a score text: </p>

<pre><code>using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Collisions : MonoBehaviour {
    public  Text scoreText;
    private float score;
    // Use this for initialization
    void Start () {
    }

    // Update is called once per frame
    void Update () {

        scoreText.text = "Score : " + score;



    }

    private void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Player")
        {
            Destroy(gameObject);
            scoreText.text = "Score : " + score;
            score++;

        }
    }

}
</code></pre>

<p>so now when I need to add the Text to the prefab I can't
and if I assign the text in somehow to the prefab it doesn't count any score  </p>

<p><a href="https://i.stack.imgur.com/wnVA0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wnVA0.png" alt="enter image description here"></a></p>