i have a game like the rool the ball game, and in my game i have a gameobject that is a gameManager, in that gameManager i instantiate the ball, what i want to do is, when my ball colides with a power add a material to a math array that is in another script, when i try accessing that script it says that Object is not instantiate, i don't know how to work on this :/.
Here is what i did
public class PowerHit : MonoBehaviour {
    MoveBall moveBall;
    Renderer rend;
    private Material yourMaterial;
    // Use this for initialization
    void Start () {
        moveBall = GameObject.FindWithTag ("Player").GetComponent<MoveBall> ();
        rend = moveBall.GetComponent<Renderer> ();
        yourMaterial = (Material)Resources.Load("Tennis",typeof(Material));
    }
    void OnCollisionEnter(Collision other)
    {
        Debug.Log (moveBall);
        if (other.gameObject.tag == "Player") {
            moveBall.mats [1] = yourMaterial;
        }
    }
}
the script that i want to acces is the MoveBall script that is atteched to my ball prefab, my ball prefa has a Player tag.
 
     
     
    