How to add to an Int every time another Int advances 500 points? [JavaScript]

Hello guys. I have a script where it adds a score using [var]++. I also have another script which is supposed to add a coin every time it adds 500 points. However, it’s not working very well.

Anyone have any tips to do it? Because I know how to check if it is at 500 points, but not if it has added up 500 points.

A thing to fi that would be to put this code in the update function that is supposed to add coins

function Update(){
    if(points%500==0 && points!=0){
    coins++;
    }
}

what this does is that every time the points gets to 500, 1000, 1500… It will add a coin. Hope this helps!