Health on photon

So guys i’m getting here an error and i cant get what´s the problem can some one help me please?

these are the errors :
Assets\Health.cs(17,48): error CS0411: The type arguments for method ‘GameObject.GetComponentInChildren()’ cannot be inferred from the usage. Try specifying the type arguments explicitly.

Assets\Health.cs(22,13): error CS0411: The type arguments for method ‘Component.GetComponent()’ cannot be inferred from the usage. Try specifying the type arguments explicitly.

using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class Health : MonoBehaviour
{
    public float hitPoints = 100f;
    float currentHitPoints;

    public Text healthText;

    // Start is called before the first frame update
    void Start()
    {
        
        currentHitPoints = hitPoints;
        healthText = GameObject.Find("Canvas").GetComponentInChildren();
    }

    void Update()
    {
        if (GetComponent().isMine) { healthText.text = "Health: " + currentHitPoints; }


    }



    [PunRPC]
    public void TakeDamage(float amt)
    {
        
        currentHitPoints -= amt;

        if (currentHitPoints <= 0)
        {
           
            Die();
        }
    }


 

    void Die()
    {
        if (GetComponent<PhotonView>().instantiationId == 0)
            
        {
            Destroy(gameObject);

        }
        else
        {
            if (GetComponent<PhotonView>().isMine)

                if (gameObject.tag == "Player")
                {
                    NetworkManager nm = GameObject.FindObjectOfType<NetworkManager>();
                    nm.standbyCamera.SetActive(true);
                   nm.respawnTimer = 5f;
                }

            {
                PhotonNetwork.Destroy(gameObject);
            }
        }

    }


}

When you use GetComponent, you need to specify the component’s type. A single GameObject can have multiple components, so you need to clear things up.

healthText = GameObject.Find("Canvas").GetComponentInChildren<Text>();

// I assume that you are trying to access PhotonView here
GetComponent<PhotonView>().isMine

Side note: don’t use GetComponent in Update. Assign it to a variable on Start so you can use that later.

PhotonView photonView;

void Start()
{
   photonView = GetComponent<PhotonView>();
}

void Update()
{
   if(photonView.isMine)
   {
      // Your code
   }
}

GetComponentInChildren expects a type to be given. Lets say you want to find the component “BoxCollider”.

For that you would do

GameObject.Find("Canvas").GetComponentInChildren<BoxCollider>();

Tnx mate it realy worked i’m leaving here the script it can help later on somebody

using System.Collections;
using UnityEngine;
using UnityEngine.UI;

public class Health : MonoBehaviour
{
    public float hitPoints = 100f;
    float currentHitPoints;

    public Text healthText;


    PhotonView photonView;

    // Start is called before the first frame update
    void Start()
    {
        
        currentHitPoints = hitPoints;
        photonView = GetComponent<PhotonView>();
        healthText = GameObject.Find("Canvas").GetComponentInChildren<Text>();
    }

    void Update()
    {
        if (photonView.isMine)
        {
            healthText.text = "Health: " + currentHitPoints;
        }


    }



    [PunRPC]
    public void TakeDamage(float amt)
    {
        
        currentHitPoints -= amt;

        if (currentHitPoints <= 0)
        {
           
            Die();
        }
    }


 

    void Die()
    {
        if (GetComponent<PhotonView>().instantiationId == 0)
            
        {
            Destroy(gameObject);

        }
        else
        {
            if (GetComponent<PhotonView>().isMine)

                if (gameObject.tag == "Player")
                {
                    NetworkManager nm = GameObject.FindObjectOfType<NetworkManager>();
                    nm.standbyCamera.SetActive(true);
                   nm.respawnTimer = 5f;
                }

            {
                PhotonNetwork.Destroy(gameObject);
            }
        }

    }


}