i have a script but there is a problem :

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class enemy : MonoBehaviour {

//public Collider player_box;

public Rigidbody rb;

private Vector3 posa;
//public Transform posb;

public float speed;

private GameObject player;

public bool right;

private move_idea move_idea_script;

void Start ()
{
	player = GameObject.FindGameObjectWithTag ("Player");
	posa = gameObject.transform.position;
	move_idea_script = GetComponent<move_idea>();

}

// Update is called once per frame
void FixedUpdate () {
	if(right==false)
	{
	rb.velocity = Vector3.left * speed * Time.deltaTime;

	}

	if(right==true)
	{
		rb.velocity = Vector3.right * speed * Time.deltaTime;
	}

}

void OnTriggerEnter(Collider other)
{
	if (other.isTrigger) {

		gameObject.SetActive (false);
		gameObject.transform.position = posa;
		gameObject.SetActive (true);

	}

	if (other.gameObject.tag == "Player") {

		player.transform.localScale = new Vector3 (player.transform.localScale.x, 0.1f, player.transform.localScale.z);

		move_idea_script.enabled =false;
		//player_box.isTrigger = true;

		Destroy (player, 1);

	}
}

}

it compile but when i run the gun the script pop up and says gameobject not set as an instance of …

if any one can help meee !!!

Without knowing what line the null reference is on, I’d assume the Rigidbody rb reference is causing the problem. You’re not assigning it in the Start method, so unless you assign it in the inspector, you’d get a “gameobject not set” error.