how do I do that?

hello, in my game, I created a team system, one blue and one red, and for the players to know who is the enemy and who is not I thought about putting their nicknames from the pain of your team, but for some reason this it doesn't work even if it doesn't give an error.

first I created a code that instantiates the player and gives him the team he had chosen:
using UnityEngine;
using UnityEngine.UI;
using Photon.Pun;
using Photon.Pun.UtilityScripts;

public class Manager : MonoBehaviourPunCallbacks {
    private bool redbool;//variavel de controle.
    private bool bluebool;//variavel de controle.
    public PhotonTeam blue;//contem o nome e o código da equipe.
    public PhotonTeam red;//contem o nome e o código da equipe.
    public Transform spawnvermelho;//vetor de localização.
    public Transform spawnazul;//vetor de localização
    public GameObject PlayerPrefab;
    // Use this for initialization
    void Start()
    {
        SpawnPlayer();
    }
    void SpawnPlayer()
    {
        if (PlayerPrefs.GetInt("team") == 0)//resgata o valor da key no sistema e o verifica.
        {
            GameObject player = PhotonNetwork.Instantiate(PlayerPrefab.name, spawnvermelho.transform.position, spawnvermelho.transform.rotation);//instancia o prefab na cena.
            player.tag = "Time Vermelho";
            PhotonNetwork.LocalPlayer.JoinTeam(red.Code);//define o time do prefab.
            print("O Player: " + PhotonNetwork.LocalPlayer.NickName + "acaba de entrar no time: Vermelho");//retorna a mensagem no console
        }
        if (PlayerPrefs.GetInt("team") == 1)//mesma descrição acima.
        {
            GameObject player = PhotonNetwork.Instantiate(PlayerPrefab.name, spawnazul.transform.position, spawnazul.transform.rotation);
            player.tag = "Time Azul";
            PhotonNetwork.LocalPlayer.JoinTeam(blue.Code);
            print("O Player: " + PhotonNetwork.LocalPlayer.NickName + "acaba de entrar no time: Azul");
        }
    }
}

and then I created the player code, the nick information is in awake:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using UnityEngine.UI;

public class Player : MonoBehaviourPun, IPunObservable
{
    public PhotonView pv;
    public float maxSpeed;
    public float jumpforce;
    private GameObject sceneCamera;
    public GameObject PlayerCamera;

    private Vector3 SmoothMove;
    private Color cor;
    private SpriteRenderer sprite;
    private Rigidbody2D rd2d;
    private bool isgrounded;

    public Text nickname;
    public Transform groundcheck;
    public Transform bulletspawn;
    private bool jumping;
    

    //ui dano
    void Start()
    {
        if (pv.IsMine)
        {
            sprite = GetComponent<SpriteRenderer>();
            nickname.text = PhotonNetwork.NickName;
            if (gameObject.tag == "Time Azul") {nickname.color = Color.blue; }
            if (gameObject.tag == "Time Vermelho") { nickname.color = Color.red; }
            rd2d = GetComponent<Rigidbody2D>();
            sceneCamera = GameObject.FindGameObjectWithTag("MainCamera");
            sceneCamera.SetActive(false);
            PlayerCamera.SetActive(true);
        }
        else
        {
            Destroy(PlayerCamera);
            nickname.text = pv.Owner.NickName;
            if (gameObject.tag=="Time Azul") { nickname.color = Color.blue;print("azul");}
            if (gameObject.tag == "Time Vermelho") { nickname.color = Color.red;print("vermelho");}
        }
    }
    private void Update()
    {
        if (pv.IsMine)
        {
            ProcessInput();
        }
        else
        {
            SmoothMoviment();
        }

    }
    private void SmoothMoviment()
    {
        if (gameObject.tag == "Time Azul")
        {
            sprite.color = Color.blue;
        }
        if (gameObject.tag == "Time Vermelho")
        {
            sprite.color = Color.red;
        }
        transform.position = Vector3.Lerp(transform.position, SmoothMove, Time.deltaTime * 10);
    }
    private void ProcessInput()
    {
        float movi = Input.GetAxis("Horizontal");

        rd2d.velocity = new Vector2(movi * maxSpeed, rd2d.velocity.y);
        isgrounded = Physics2D.Linecast(transform.position, groundcheck.position, 1 << LayerMask.NameToLayer("FLOOR"));
        if ((movi > 0f && sprite.flipX) || (movi < 0f && !sprite.flipX)) { Flip(); }
        if (Input.GetKeyDown(KeyCode.Space) && isgrounded)
        {
            jumping = true;
        }
        if (jumping == true)
        {
            rd2d.AddForce(Vector2.up * jumpforce);
            jumping=false;
        }
    }
    void Flip()
    {
        sprite.flipX = !sprite.flipX;
        if (!sprite.flipX)
        {
            bulletspawn.position = new Vector3(this.transform.position.x + 10f, bulletspawn.position.y,
                bulletspawn.position.z);
        }
        else
        {
            bulletspawn.position = new Vector3(this.transform.position.x - 10f, bulletspawn.position.y,
                bulletspawn.position.z);
        }

    }
    [PunRPC]
    void OnDirectionChange_LEFT()
    {
        sprite.flipX = true;
    }
    [PunRPC]
    void OnDirectionChange_RIGHT()
    {
        sprite.flipX = false;
    }
    
    public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
    {
        pv.sin
        if (stream.IsWriting)
        {
            stream.SendNext(transform.position);
        }
        else if (stream.IsReading)
        {
            SmoothMove = (Vector3)stream.ReceiveNext();
        }
    }
    
}


Please help me.
Sign In or Register to comment.