Track speed after OnTriggerEnter

Hi,
I have a Problem:
I am writing in one script, I want to do this:
if (something)
{get script2, get the position of the object at this moment, which last entered the Collider }

but what I get is
{get script2, get the position of the object at the moment when it hits the Collider, which last entered the Collider }

what can I do?

That is working properly. If you’re wanting to do this under another condition other than OnTriggerEnter() Store the last object to enter the trigger as a GameObject variable then put the ‘if (something)’ where ‘something’ is being altered in the script or put it in Update().

If you save a reference to the game object that last entered the trigger you can get the information from it later when you need it, instead of saving the position on the moment it enters the trigger:

public class ScriptOneName : MonoBehaviour
{
	//A variable for saving the game object.
	public GameObject lastEnteredTrigger;
	public bool someBoolean = false;
		
	public void OnTriggerEnter(Collider other)
	{
		//Before you assign the gameobject, you might want to check if it's the right gameobject
		//Do this by checking the tag, the name, if it has the right script etc...
		//if(other.gameObject.tag == "niceTag"){...
		//if(other.gameObject.name == "niceName"){...
		//if(other.gameObject.GetComponent<ScriptTwoName>() != null){...
		
		lastEnterTrigger = other.gameObject;
	}
	
	public void CheckPositionLastGameObject()
	{
		//Check if someBoolean is true and if a gameobject has entered the trigger earlier:
		if(someBoolean && lastEnteredTrigger != null)
		{
			Vector3 currentPosition = lastEnteredTrigger.transform.position;
			ScriptTwoName scriptTwo = lastEnteredTrigger.GetComponent<ScriptTwoName>();
		}
	}
}

// script1: if player reaches a position, then call script2, the the cars speed at this moment
void Update ()
{ if (PlayerReference.transform.position.x > 0)
{
GameObject stopper2 = GameObject.Find(“Stoppuhr2”);
Stopwatch2 Stopwatch_script2 = stopper2.GetComponent();
Debug.Log(Stopwatch_script2.carposition_z);
}
}

script2:
 void OnTriggerEnter(Collider other)
    { carposition_z = other.transform.position.z}

what do you mean by “save as Gameobject variable”? How can I do it?