Ads on death problem

I have script (ManagerScript) where I have PlayRewardedAd void which plays rewarded ad , but when I attached this components to other script nothing happens (when player dies for 15th - by hitting a bottom wall- ad won’t play,instead ball just bounces up from wall).So Unity recognizes some action on 15th death ,but not correct action.Here’s ballscript :

using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine.Advertisements;

public class BallScript : MonoBehaviour
{
    private ManagerAds ads;
    public Vector2 startForce;

    static int times = 0;
    public Text goverText;
    public Vector3[] positions;
    public Rigidbody2D rb;

    void Start()
    {
        int randomNumber = Random.Range(0, positions.Length);
        transform.position = positions[randomNumber];
        times = PlayerPrefs.GetInt("Played:", times);
        rb.AddForce(startForce, ForceMode2D.Impulse);
        ads = FindObjectOfType<ManagerAds>();
    }

    void Update()
    {
        PlayerPrefs.SetInt("Played:", times);
        goverText.text = "Played:" + times.ToString();
    }

    void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.name == "wall_bottom")
        {
            times++;

            if (times == 15)
            {
                ads.PlayRewardedAd();
            }

            SceneManager.LoadScene("wfvv");
        }
    }
}

Same problem as Unity Ads show on 19th death in Editor , but not on Android device - Unity Services - Unity Discussions ?

Still, I would recommend you to add some debug logging, so you can e.g. check value of “times” variable. Since you set it by calling PlayerPrefs.GetInt(), it could actually start by being higher than 15, so PlayRewardedAd() newer gets called.

/Rasmus

NullReferenceException: Object reference not set to an instance of an object
BallScript.OnCollisionEnter2D (UnityEngine.Collision2D other) (at Assets/BallScript.cs:39)

I got this error in Editor , when ad should be played

Above probably has nothing to do with Ads, some suggestions for further reading:

Check line 39 to see what object is being referenced, and see why it’s not being set as expected before you try to access it.

/Rasmus

Fixed it by attaching ManagerAds script to Ball