Object reference not set to an instance of an object Unity : <p>The script is attached to a coin that when picked does that issue.
There is nothing to attach in the inspector.</p>

<p>The <code>CoinMagnet state</code> is assigned to another object (as a magnet).</p>

<pre><code>public void Start()
    {
        Player = GameObject.FindGameObjectWithTag("Player");
        pu = Player.GetComponent&lt;PowerUps&gt;();       
    }

private void Update()
    {

        if (pu.CurrentPowerState == PowerUps.State.CoinMagnet) //issue here
        {
            if (Vector3.Distance(Player.transform.position, transform.position) &lt; CoinMagnetRadius)
           ...
           ...
        }
    }

</code></pre>

<p>Here is the Powerups class</p>

<pre><code>public State CurrentPowerState;
 public enum State
    {
        None,
        Invincible,
        CoinMagnet,

    };
</code></pre>
