If I buy or sell shares on Ex-Date of Dividend announcement, Do I receive the dividend? What is the record date?

I heard from @ShubhS9 that if I buy on ex date ; the dividend would be received in the broker’s account and then the broker would pass or transfer the same to the client’s trade ledger account.

Am I right ?

But my query is ; if client 1 : buys on ex date and client 2 : sells on the same ex date ; and both the clients are of one same broker only . Then whom client would the broker pass on or transfer the dividend to ?