using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using MLAPI; using MLAPI.NetworkVariable; public class PlayerHealth : NetworkBehaviour { public Text healthValue = null; NetworkVariableFloat health = new NetworkVariableFloat(new NetworkVariableSettings { WritePermission = NetworkVariablePermission.Everyone }, 100f); // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { if (IsLocalPlayer) { healthValue.text = health.Value.ToString(); } } public void TakeDamage(float damage) { health.Value -= damage; } public void Heal(float amount) { if (health.Value <= 100f) { health.Value += amount; } } }