add score with GameObject.SetActive(/false)

Hi, I want to add score with GameObject.SetActive(/false)

Basically, particles collide with object and then object disappears, Objects disappear one by one using GameObject.SetActive(/false). Score should increase for each object that disappears.

If { } statement should work, but how?
If anyone can help please

int score = 0;

void OnCollisionEnter(Collision col) {
    GameObject.SetActive(false);
    score++;
}. 

I don’t know how your code works because you didn’t provide it but this might help. Or if the score field is in another script then score++; becomes OtherScriptName.score ++;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Wallscript : MonoBehaviour
{

   public Text scoreText;
   public int score = 0;

void Start()	{
scoreText.text = "Score + " score;	
		}

    private void OnParticleCollision (GameObject other)
		{
 	
gameObject.SetActive(false);
score++;             
		}	

}