[Solved] how to fix the scoring issue in pong game


You do a lot of stuff differently for each player for no reason. It would be much more helpful if you narrowed down what part of the code the error was coming from or at least told us which player doesn’t work and which does.

I’m not going to read all of the code you posted, but look at differences like this. The error might not be coming from setScore() alone. There is no way to tell without going through everything you posted.

if (goalon1 == true){
    scoreplayer2 ++;
}
if (goalon2 == true){
    scoreplayer1 = scoreplayer1 + 1;

}

Try to match the code for both players and I’m sure you’ll find your mistake

2

solved how to fix the scoring issue in pong game