Ruling on Flush

Could someone please clarify me this rule:
The flop , Turn and River show all Heart 2,6,7 Q and AS , meaning flush As high.
Player X had the K of H and bet 2K
Player Y folded as he had no Heart
I queried with player Y why he folded as in my view this should has been a split pot, as the As was the major card in the set. Player Y did not agreed with me as he thinks the other player (X) had a better hand with the K of h, whilst he (Y) had no heart.
I am right to assume that this should have been be a split pot despite that X had the K
If the As did not came out, then, yes X had a better hand.
Could someone confirm my reasoning , and if I am wrong then I sincerely apologise to player Y ( HenCat)
Incidentally, I personally was not involved in that hand

Player X with the K of H would have won. If neither of them had a heart the pot would have been split, but because Player X had a heart higher than the lowest card on the board he won.
It’s the best five cards so
Player Y was playing the board 2 6 7 Q A
While Player X had K 6 7 Q A.

Hopefully I explained that right

Yeah, only the guy with the king of hearts had a flush.

The other guy had 4 hearts and an offsuit ace.

5 hearts (a flush) beats 4 hearts and an ace (a good fold).

5 Hearts on the table As high, So both had the flush As high. except that player X also had the K

Thank you

Sorry, I should have read it more carefully, I thought As was ace of spades.

The guy with the king had a better flush.

As AcesShock pointed out, it was…

A K Q 7 6 (using the king from his hole cards)
A Q 7 6 2 (playing the flush on the board)

Cards in a flush are counted in descending order. AKQJT98765432A. If 2 or more players have a flush the winner is decided by the highest ranking card. If the highest ranking card is shared, as the Ace was here, the winner is decided by the next highest ranked card which in this case was the King in Player X’s hand as it outranks the strongest card (the shared queen) in Player Y’s hand. Player Y is correct.

Thank you all for this clarification. Very much appreciated