You are not allowed to call this function when declaring...

Okay, so I’m working on a melee system of sorts, a mutated version of the launcher from the FPS tutorial. As far as I can tell there is nothing wrong with my script at all, but its giving me this error:

“UnityException: You are not allowed to call this function when declaring a variable.
Move it to the line after without a variable declaration.”

it says the error is on line 5. Line 5 in my script is an empty space!

Here is my script:

var meleeCollider : Rigidbody;
var speed = 20;
var swingTimer = 0.15;
private var lastSwing = -10.0;

function Update(){

	if(Input.GetButtonDown("Fire1")){
	
		if (Time.time > swingTimer + lastSwing){

			var instantiatedProjectile : Rigidbody = Instantiate(meleeCollider, transform.position, transform.rotation);
			
			instantiatedProjectile.velocity = transform.TransformDirection(Vector3(0,0,speed));
			
			Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider);
			
			lastSwing = Time.time;
		
		}
	
	}
}

What the hell does that stupid error mean?

It must be another script, because that one is fine.

–Eric

i’ve been getting the same error. for me, the error is always on line 17. the script seems to run normal, but i can’t figure out where the error messages are coming from.

is this a glitch?