Need help with Simple script

hello community,to start this of im the biggest noob in scripting, i started scripting 2 weeks ago, and what im trying to create is a trigger zone:

ok so its pretty much like this: you walk into a trigger zone and once you collide with it i want it to spawn a prefab

how do i do this?

any help is apreciated

regards jim

var gameObject : GameObject;
var tags : String;

function OnTriggerEnter(other : Collider)
{
	if (other.gameObject.CompareTag (tags)) {
		Instantiate(gameObject, transform.position, transform.rotation);
		}
		
}

In inspector write what you want to trigger (tags) and what gameobject you want to spawn. Remember to put the collider in trigger mode. Hope that helps.

hmmm im having a weird error somthing with ambiguos? hope im not asking for to much but when it comes to errors im a super x2 noob

it says BCE0004:ambiguos reference ‘gameObjects’ : trigger Zone.gameObject, Unity.Component.gameobject.

oops wrong picture

672991--24184--$2011-08-26_1710.png

can u read, if not its in my comment above

You can’t use the ambiguos name gameObject in a monobehaviour… here is the example corrected.

var prefab : GameObject;
var tags : String;

function OnTriggerEnter(other : Collider)
{
	if (other.gameObject.CompareTag (tags)) {
		Instantiate(prefab , transform.position, transform.rotation);
		}
}