Have you got some idea how to make score script?

I need to make some score script but it must works with this: If my gameobject will be set active true score will have +1 point. Have you got some idea? If yes please help me.

Something like this:

using UnityEngine;
using UnityEngine.UI;

public class ScoreScript: MonoBehaviour
{
	int score;
    
	public Text scoretext;  //Set this in the inspector or define it in Start
	bool isObjectActive;
    
	void Start()
	{
		isObjectActive = gameObject.activeSelf;

    	if(score < 0)
    	score = 0;
    }
    
    void Update()
    {
		if(gameObject.activeSelf != isObjectActive)
		{
			score++;
			isObjectActive = gameObject.activeSelf;
		}

		scoretext.text = "" + score;
    }
}