My damage script not synchronize from other to other.

Options

How to synchronize my multiplayer fighting game from owner to client? My multiplayer games works fine from Transform view until animator view. But when a player tries to damage on each other, the health points only appear reduced on each client, and not synchronized between clients. If in client 1 player 2 is dead, but in client 2, player 2 is not dead.


This is my Combat Damage Scripts

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;

public class dataHP : MonoBehaviourPunCallbacks
{
    public Animator animator;
    public healthBar hb;
    public int maxHP = 100;
    int HPsekarang;
    // Start is called before the first frame update

    void Awake()
    {
        hb = GetComponent<healthBar>();
    }

    void Start()
    {
        HPsekarang = maxHP;
        hb.SetMaxHealth(maxHP);
    }

    // Update is called once per frame
    void Update()
    {
        
    }

    public void TakeDamage(int damage)
    {
        HPsekarang -= damage;
        hb.SetHealth(HPsekarang);
        animator.SetTrigger("isHurt");
        if(HPsekarang <= 0)
        {
            Die();
        }
    }

    void Die()
    {
        Destroy(gameObject);
        return;
    }
}

Answers