Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

The referenced script on this Behaviour is missing!

Discussion in 'Scripting' started by Devidze, Jul 11, 2015.

  1. Devidze

    Devidze

    Joined:
    Jul 10, 2015
    Posts:
    6
    i had a problem with a script, but i fixed it and here is an another problem about that a same script which i have fixed erlyier. so im trying to say that in scripts everything is allright, i chacked it many times and but every time when im trying to enter a play mode i get this message: "The referenced script on this Behaviour is missing!" please help me if you can. here is my script picture :
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections;
    4.  
    5. public class ball : MonoBehaviour {
    6.    
    7.     public float ballVelocity = 3000;
    8.    
    9.     Rigidbody rb;
    10.     bool isPlay;
    11.     int randInt;
    12.    
    13.     void Awake ()
    14.     {
    15.         rb = gameObject.GetComponent<Rigidbody>();
    16.         randInt = Random.Range (1,3);
    17.     }
    18.    
    19.     void Update ()
    20.     {
    21.         if(Input.GetMouseButton(0) == true && isPlay == false)
    22.         {
    23.             transform.parent = null;
    24.             isPlay = true;
    25.             rb.isKinematic = false;
    26.             if(randInt == 1)
    27.             {
    28.                 rb.AddForce(new Vector3(ballVelocity,ballVelocity,0));
    29.             }
    30.             if(randInt == 2)
    31.             {
    32.                 rb.AddForce(new Vector3(-ballVelocity,-ballVelocity,0));
    33.             }
    34.         }
    35.     }
    36. }
    37.  
     
  2. magnite

    magnite

    Joined:
    Dec 12, 2012
    Posts:
    125
    Check the objects in your scene. One of them has a script attached to it but its link is missing. So check each object in the inspector to make sure no scripts are missing.
     
  3. Devidze

    Devidze

    Joined:
    Jul 10, 2015
    Posts:
    6
    first everything was fine when i wrote first script about paddle (first object) everything was working perfectly but then i wrote other script for a ball (another object) this error massage maybe damaged the first object too, i mean after a second script everything gone wrong but i cant find a mistake (im trying to make a pong game by the way) here is some screenshots:
     

    Attached Files:

  4. SkillBased

    SkillBased

    Joined:
    Aug 11, 2014
    Posts:
    141
    Make sure your scripts are all attached to GameObjects in your hierarchy pane. Its easy to miss this detail...