How to change players name in the chat?

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to be able to change the players name in the chat, and not just like set as soon as they join I need to be able to change it whenever it is needed.

  2. What is the issue? Not sure where to start

  3. What solutions have you tried so far? Looked on the forums but didnt find anything useful to me

So I used this guys solution and it works but I’m not sure how I would change the players name mid game.