script class cant be found
whenever i try to add a script onto this empty game object it says that the script can't be found the full error is: cant add script component 'opening' because the script class cannot be found. make sure there are no compile errors and that the file name and class name match.
Answer by evannagel · Jun 09, 2020 at 01:21 PM
Im guessing that you have either deleted or renamed a script. This often causes Unity to throw this error because Unity thinks this script still exists.
Answer by residenteviljoe · Jun 10, 2020 at 09:37 AM
no it does not work but here is the script anyway using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class opening : MonoBehaviour {
public GameObject theplayer;
public GameObject fadescreenin;
public GameObject textbox;
void Start()
{
theplayer.GetComponent<FirstPersonAIO>().enabled = false;
StartCoroutine(scenePlayer());
}
IEnumerator scenePlayer ()
{
yield return new WaitForSeconds(1.5f);
fadescreenin.SetActive (false);
textbox.GetComponent<Text>().text = "where am i?";
yield return new WaitForSeconds(2.0f);
textbox.GetComponent<Text>().text = "i need to get out of here";
yield return new WaitForSeconds(2.5f);
textbox.GetComponent<Text>().text = "";
theplayer.GetComponent<FirstPersonAIO>().enabled = true;
}
}
Answer by zacsheldo · Mar 21, 2021 at 02:06 PM
I have a similar problem. I'm loosely following a Brackys tutorial on a multiplayer fps engine. And I cant add the script to the player object. The name and class are exactly the same. The script looks like this.
using UnityEngine.Networking; using UnityEngine;
public class PlayerS : NetworkBehaviour { [SerializeFeild] Behaviour[] componentsToDisable;
void Start()
{
if (!isLocalPlayer)
{
for (int i = 0; i < componentsToDisable; i++)
{
componentsToDisable.[i].enabled = false;
}
}
}
}