spawn object every 10 score points

Hi, I’m new to scripting. I would like to know how I can instantiate an object every 10 score points?

This should work:

gameObject obj;
int score;
int oldScore;

if (score == oldScore + 10)
{
    Instantiate(obj);
    oldScore = score;
}