If/Else If/Else Statement

Hey all,

Got a bit of a problem with the code I am writing for a small game.

It’s a horse racing game and what I am trying to achieve is if player 1 collides with the goal then the well done message shows. If player 2 collides with the goal then the oh dear message will show up. Sounds simple enough but I can’t figure out where i’ve gone wrong.

if  ( player1.hitTestObject( goal ) ) {

    wellDone.visible = true; //Turns oh dear message visible.
    
    } else if ( player2.hitTestObject( goal ) ) {
        
    ohDear.visible = true; //Turns well done message visible.
    
    } else { 
    
    trace("neither are true");

    }