run code once every 10 second

Hi , i want to run some code once in prude of time , for example show value of x every 10 second , i use this code :

	int x = 0;
        void Update () {

        if ((int)Time.time % 10 == 0 && Time.time > 3 )
        {
            
            Debug.Log(x++);
            
        }
        //Debug.Log((int)Time.time);
	}

but after first perude my output in console show x value from 0 to 187 !
how can i run Debug.Log(x++) once every 10 second
thanks

Your code will log c during the 10th second for as many times as you get frames per second. You’ll need to remember after logging x for the first time during the 10th second, then again during the 20th second and so on.