Desync is ruining my game, what do I do?

How do I fix/ manage desync in multiplayer? I’m currently making a top down soccer like game, and sometimes the ball desyncs and will score on one players screen but remain in play for the other. This makes the giant block of code shared below only run for the person that sees the ball go in, and it completely breaks my game. How do I manage this?