this the script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DestroyOutOfBounds : MonoBehaviour
{
public GameObject text;
private int topBorder = 40;
private int bottomBorder = -5;
public int i = 0;
// Start is called before the first frame update
void Start()
{
text.SetActive(false);
}
// Update is called once per frame
void Update()
{
if (transform.position.z > topBorder)
{
Destroy(gameObject);
}
if (transform.position.z < bottomBorder)
{
Destroy(gameObject);
i++;
}
if (i > 3)
{
text.SetActive(true);
}
}
}