Trigger Respawn

I’m making car game, and you pull up to a intersection and you have to answer the question. I want to have it so if they get it wrong and drive the wrong way that I can use a trigger to respawn them back before the question.

function OnTriggerEnter (Collision : Collider)
{
transform.localPosition = Vector3(1085,3,944);
transform.rotation = Quaternion.identity;
transform.Rotate(Vector3.up * 0, Space.World);
}
How can I have it so I have that on my cube trigger and it’ll take my car and not my trigger to that position

Your question is not really clear, but I believe that your problem comes from the use of the ‘transform’ variable.

transform (the reference of the current objects’ transform), different from ‘Transform’ (the object class), indicates the transform property of the object the script is running from.

So if you attach the script to a cube, and type

transform.Translate(1,0,0);

the cube will translate 1 unit to world right direction.

What you need instead is to acces the ‘other’ object transform, which is conveniently accessible through the ‘collider’ parameter that the trigger functions allow.

function OnTriggerEnter (Collision : Collider) <= your definition is wrong, since Collision is a system object
function OnTriggerEnter (other : Collider) <= you need to use this definition instead

inside the function then, you use

other.transform.Translate(1,0,0);

and this will move the object that entered the collider, rather than the cube the script is attached to!

Add a property to the cube trigger code:
public GameObject Car;
Then on the triggerEnter code:
Car.transform.localPosition = Vector3(1085,3,944);
Car.transform.rotation = Quaternion.identity;
Car.transform.Rotate(Vector3.up * 0, Space.World);
Now save the code, in the Hierarchy select the cube, and then drag and drop your car object into its inspector window (on top of Car property).

This was one way of doing it.
The other way is to have your car having a unique Tag.
And then use GameObject.FindWithTag(“the tag you chose for the car object”) in the on trigger to get the car object. So you don’t have to drag drop the car object to the cube inspector anymore.

public GameObject.FindWithTag(“Car”);

function OnTriggerEnter (Collision : Collider)
{
Car.transform.localPosition = Vector3(901.2015,-0.02017058,936.0092);
Car.transform.rotation = Quaternion.identity;
Car.transform.Rotate(Vector3.up * 90, Space.World);
}
when I put that in it gives me a unexpected token: Game Object error