Investment Gone Wrong

In 2019 January, I invested money into a friend (X) for share market. Another of my friend(Y) also joined the investment next month. The dealing was all verbal and chat with no official agreement. The transactions were all online. My friend Y trusted me and invested the amount with the friend X. Y never met X nor he talked, as I was the one in between them for conversations and dealing. I had kept transparency with Y that the investment was being sent to X. I even have bankstatement proof of it. We got profit only (Capital wasnt returned) and we kept on reinvesting more money with (X) until 2021 December. We were getting returns until July 2021. But the friend stopped sending investment returns after that and didnt state the reason. He made up promises to send the money as the market was down etc. But later in April 2022 he revealed he has lost the money in share market. Feb 2021 Was the last time he had last sent money. (Not capital return) The transactions happened like this from start: I was receiving money from Y and sending it to X, sometimes Y directly sent money to X as I had said him to. And the profit I was receiving from X I used to send Y as per the profit percentage that was decided. Y used to always ask me if the investment was safe, I had assured him that yes its safe because the friend X is our friend. I used to ask friend X the same thing, he used to assure the same verbally. Now its been over a year, the investment has gone bad and the friend X has been communicating regularly and accepting his fault and promising to return the capital money, but he could not as he states he is trying many sources to get money but unable to do so and giving us trust that it is his fault that his investment went bad and he will return the capital amount. However the Friend Y who had investment, is going mad, angry and impatient and blaming me for the loss as I had earlier assured it is safe. I shared recordings, chats of conversations between me and X & made him directly talk with the friend X and he knew that genuinely his money was invested And the friend X is trying to recover the money to return. But the friend Y is getting impatient and warning to go to court or file FIR against me and the friend Y. So in this case the friend X is regularly communicating that he will return the money but failing to do so. He had earlier given dates of returning the money but has been failing from the last 5 months to stick to return any money. Now he is still communicating and asking for time as he is trying to get some loans and likewise with time return the money. The arrangement of money is taking time. Both mine and my friend money are stuck but I am stuck in between, communicating in between and trying to handle the friend Y from not making anything legal case as the friend X is keeping on ensuring that he will return the amount. What can go wrong for me and how to recover money especially for friend Y.