Adding and getting Players score in team.

saad
saad

Hi! I'm very new in photon. Right know I'm making a score system on network

I have a goal game scenario when a player 1 make a goal to player 2 I add a score to player 1 who make a goal and same with second player, its working fine both players can see each others score on screen,

But the issue is when I play 2 VS 2 and if the one player make a goal the all players got a score

and some time, some players got a score , In 2 Vs 2 score system is not working proper,

I have script on player goal net when a Ball hit using this way i add score;

if (other.gameObject.tag=="BIGBALL")
{
    allPlayers = FindObjectsOfType<PlayerMover>().ToList();
    for (int i = 0; i < allPlayers.Count; i++)
    {
        if (allPlayers[i].PV.IsMine)//&& !addscore )
        {
            if (id != allPlayers[i].playerID)
            {
                allPlayers[i].PV.Owner.AddScore(1);
                    //addscore = true;
            }
        }
    }

And in GameManager script I make a function and call it in each player script using

InvokeRepeating the function is:

public void updateScore()
{
   int TeamOneScore=0;
   int TeamTwoScore=0;
   
   for (int i = 0; i < PhotonNetwork.PlayerList.Length; i++)
   { 
       //if(PhotonNetwork.PlayerList[i].CustomProperties["Team"]== PhotonNetwork.LocalPlayer.CustomProperties["Team"])
       if(PhotonNetwork.PlayerList[i].CustomProperties["PlayerID"]== PhotonNetwork.LocalPlayer.CustomProperties["PlayerID"])
       {
            TeamOneScore+=PhotonNetwork.PlayerList[i].GetScore();
       }
       else 
       {
            TeamTwoScore += PhotonNetwork.PlayerList[i].GetScore();
       }
       
   }
   text0.text = TeamOneScore.ToString();
   text1.text = TeamTwoScore.ToString();
}

anyone who help me.