SInce when?!?!? (Raycast issue)

okay, I don't use raycast a lot, but I've seen a pretty good deal of scripts that use a raycast and get info back from it. I copy/pasted the raycast part of this script and just changed the variable names. here's what I have

var target : Transform;

function Update () {

if (!target){

transform.Rotate(0,50,0);
// raycast

var hit : RaycastHit[];
  hit = Physics.RaycastAll(transform.position, transform.forward, 100.0);
if (hit.collider.gameObject.tag == "PBP"){

    //target = hit.collider.gameObject;

}}}

I just want to assign the hit object as my target, but I get an error message : Assets/Scripts/BuildPoint.js(12,9): BCE0019: 'collider' is not a member of 'UnityEngine.RaycastHit[]'.

Since when is collider not a member of raycast hit? The api clearly states that it is, and I've seen loads of scripts use it. What am I doing wrong?

Remove the [] after RaycastHit.

By putting a [] after it you are getting an array of everything that was hit (I think - someone feel free to correct me if I'm wrong)

You are then trying to do array.collider which does not exist since hit refers to an array of hits.

EDIT: Your code is slightly off. Try this:

var hit : RaycastHit;
if (Physics.Raycast (transform.position, -Vector3.up, hit, 100.0)) {
if (hit.collider.gameObject.tag == "PBP"){
  //do your stuff
}
}

The problem is not that use you RaycastAll which returns RaycastHit[] instead of Raycast which returns RaycastHit. The problem is that you don't use the information RaycastHit[] returns correctly. Instead of checking wether it is a collider with a certain tag you must check if it contains a collider with that tag. So simply loop through it using

for(i=0;i<hit.length;i++) {
    if (hit*.collider.gameObject.tag == "PBD"){*
 _target = hit*.collider.gameObject;*_
 _*return;*_
 _*}*_
_*}*_
_*```*_