how would i get this code to wait for the time i put in the inspector

var componentType : String;

function OnTriggerEnter (hitPlayer : Collider) {
	if(hitPlayer.gameObject.tag == "Army Cube" || "Gold Cube" || "Flame Cube" || "Gravity Cube" || "Ice Cube" || "Mini Cube") {
	
    var added : Component = gameObject.AddComponent(componentType);
    
    added.enabled = false;
}
}

How could i make it to were i can make this script wait to add component, i know you would use “yeildforseconds” but i want to be able to change the seconds in the inspector and if it has no time to wait to not wait at all thanks for any help

First, we put the delay in the inspector:

var triggerDelay : float = 1.0;

After compiling, you should see “Trigger Delay” in the inspector. Given the above, it will default to one second.

Later, you can reference that variable in your code:

yield WaitForSeconds(triggerDelay);

You can wrap the yield in control logic, so that it will only be executed in certain conditions:

if (triggerDelay > 0.0) {
    yield WaitForSeconds(triggerDelay);
}