Spawning with trigger

Hello I’m making a fps game, my plan is to make a “flag” which would let a player trigger it, and when he triggers it, it spawns something where empty gameObject is…but I would like to make it like if 1 team has triggered the flag other team cant trigger it till first team doesnt move from trigger…This is last thing that I need in my game…can some1 pls help

var redFlag:Transform;
var scoringBlPlyr:Transform;//scoring blue player
var bluDis= Vector3.Distance(scoringBlPlyr.position, redFlag.position);
var blueTeamScored=false;
var xAmount= 5.0;//distance from flag where blue scoring player must remain
var redCanTrigger=true;
function Update(){
if (blueTeamScored==true)
if (BluDis<xAmount)
redCanTrigger=false;
}

You could setup collision layers for each team and use trigger colliders on the flag.

On the flag script, add a public Transform variable to be your spawn location, which you then set in the inspector. Also add a public GameObject variable to be your prefab, which describes what to spawn. Also set up that variable in the inspector.

In OnTriggerEnter, Instantiate the prefab, and set its position to your spawns position.

#pragma strict

var spawn : Transform;
var prefab : GameObject;
    
// Assume layers have been set up!
function OnTriggerEnter(other : Collider) 
{
    Instantiate(prefab, spawn.position, spawn.rotation);
}

And if you want to add a cooldown timer to only trigger every x seconds etc…

#pragma strict

var spawn : Transform;
var prefab : GameObject;
var cooldown = 5f; // 5 second trigger cooldown by default
    
private var cooldownExpiry = 0f;
    
// Assume layers have been set up!
function OnTriggerEnter(other : Collider) 
{
    if (Time.time < cooldownExpiry)
        return;
            
    Instantiate(prefab, spawn.position, spawn.rotation);
    cooldownExpiry = Time.time + cooldown;
}