using UnityEngine; public class TreasureItem : MonoBehaviour { private void OnTriggerEnter(Collider other) { // Kiểm tra xem thứ chạm vào có script PlayerInventory không PlayerInventory player = other.GetComponentInParent(); if (player != null && !player.hasTreasure) { player.hasTreasure = true; Debug.Log("Đã nhặt kho báu!"); // Làm vật phẩm biến mất gameObject.SetActive(false); // Hoặc Destroy(gameObject); } } }