'Photonview.owner.nickname not working properly for Clients

I'm working on photon game where I have to show the player name over their everything is working fine but there's an issue , when you create a room and join it , the host name is properly visible to everyone but when it comes to the client Client name is some random numbers even though client is also setting their user name before joining the room , here's my code which is handling the naming system

public void JoinRoom()
{
    connectButton.interactable = false;
    PhotonNetwork.NickName = userId.text;
    PhotonNetwork.JoinRoom("Basic");
}    


Solution 1:[1]

Try this

    PhotonView view;
    
void Start()
    {

        view = GetComponent<PhotonView>();
    }
void JoinRoom()
    {
        if(view.IsMine)
        {
            userId.text = PhotonNetwork.NickName;
        }else

        {
            userId..text = view.Owner.NickName;
        }
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Akshay Kumar