"The referenced script on this behavior is missing!" in Roll-a-ball tutorial.

Hello, I’m new to unity(5) The roll-a-ball tutorial (https://unity3d.com/learn/tutorials/projects/roll-ball-tutorial) (step 2) requires code in C# fallowing the tutorial we obtain the fallowing code:

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {
	
	private Rigidbody rb;
	
	void Start ()
	{
		rb = GetComponent<Rigidbody>();
	}
	
	void FixedUpdate ()
	{
		float moveHorizontal = Input.GetAxis ("Horizontal");
		float moveVertical = Input.GetAxis ("Vertical");
		
		Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
		
		rb.AddForce (movement);
	}
}

In the tutorial the sphere moves, when I hit the play button in editor I remain in same position (0,0.5,0) and I get the fallowing error: “The referenced script on this behavior is missing!” twice.

After some searching from this source(Move a ball using keybored - Questions & Answers - Unity Discussions) I’ve tried the fallowing:

using UnityEngine;
using System.Collections;

public class PlayerController : MonoBehaviour {
			
	public int speed = 5;
		
	void FixedUpdate () 
	{ 
		float x = Input.GetAxis("Horizontal"); 
		float z = Input.GetAxis("Vertical");


		transform.Translate(x, 0.0f, z);
	} 
}

But got the same error “The referenced script on this behavior is missing!” twice

Is there something wrong with the code? Am I missing something?

Hi there,

I have tested your code just to be sure. I can tell you it’s working.

However your problem doesn’t directly relate to your code.

what you need to check is, if your script is still referencing in your editor, like as your error says The referenced script is missing.

Since you are new to this, I’ll try and guide you as best as I can.

  1. Click on your object that you are trying to move, which I assume in your case is the sphere.
  2. You have a script put on this object, so in your editor of that object check the script, see the picture below(I have highlighted in red at what should be almost the same for you):

if that is not there you have located the source of the problem. you need to simply double click it and select the desired script and everything should work as intented.

I hope this helps :slight_smile: