Prefab Enemy - Cannot convert 'UnityEngine.GameObject' to 'UnityEngine.Rigidbody'.

I have an enemy that works fine until I make it a prefab. There is an Enemy script with the player dragged into the inspector so I tried to use Find to avoid this for the prefab; however, now I get the error above since I Find the player GameObject yet I’m doing a Rigidbody to it later.

I’m using javascript.

Here’s my code
#pragma strict

var player : Rigidbody;
var bounceAmount = 5f;

var deathParticles : Transform;

//Enemies don't work since the player isn't found.
//The following is trying to remedy that for the "Enemy" script
function Awake() {
	player = GameObject.Find("Player");
	Debug.Log("Enemy script - was able to Find Player");

function Die () {

    player.GetComponent.<Rigidbody>().velocity.y = bounceAmount;

    Instantiate (deathParticles, transform.position, transform.rotation);
    Destroy (gameObject);


I looked at other solutions and tried “as Rigidbody” but still got the same error. I tried to Find a Rigidbody instead but it wouldn’t let me do that.


var player : GameObject;

var player : GameObject;

just use it
1st line

Thanks guys. That solved the error but I got a Null Reference error after that. I solved it by changing

player = GameObject.Find(“Player”);


player = GameObject.Find(“Ball”);
which is my player GameObject and now it WORKS!!!

Thanks again