when OnMouseDown() is on the right timing, it triggers an event. How to achieve it?

Basically, I am planing to use co-routine and WaitForSeconds(waitTime); to count the beats. The player scores when he clicks the the gameObject right on the beat.

Let’s Say the waitTime is 1 second, the script will run a function every 1 second to check if the player clicks the gameObject. It allows the player to have +/- 0.1 second error when hitting the button. How do I achieve this?

It looks you are on the right track. Just put the content of your coroutine in a “while (true)” loop and your rightOnTime bool will behave correctly I believe.

I would do way different than that. Maybe you record every clicks and the time it was made, and doing a very simple math you can extract how many clicks, the order and the time it took between 1 click and another.