- Home /
Scripting Issue. Class and File Name
Okay I have a really pain in the ass problem in Unity lately (or ever since I started). Every script I create, once I attach it to say my player, it says "cant add script behaviour __. The scripts file name doesn't match the name of the class defined in the script." Now I know this means my file name and class name are different USUALLY. But i write them in exactly the same. I'll send two pictures within showing the class name and the file name.can someone please help me. Im really nterested in scripting.
IIRC, I've sometimes managed to get that error when defining multiple classes in the same file. Any chance that's your issue, here?
When you have multiple $$anonymous$$onoBehaviors in one file, that's when I usually get it. Got it once when I accidentally defined two classes as the same name, but I'm guessing it's when it returns false on finding the main class.
Answer by Bunny83 · Oct 20, 2013 at 10:06 AM
Are you sure that you don't have some critical compiler errors in your console? If so, your scripts probably aren't even compiled yet.
Make sure when you click on the clear button in your console window that the window is empty. If there are any errors pending, fix them.
edit
ps: make sure you don't have the same script multiple times. Namespaces are only partly supported. Your MonoBehaviour classnames still have to be unique.
@masterlewis2002: Uhm, may i ask what you're referring to? As far as i can tell you're not the OP of this question. If you have a similar problem you have to give more information. For this it might be better to ask a seperate question.
If you still "don't know what to do" you can go for a walk or watch a movie. Just a suggestion :D
Uhm, well you click the clear button:
If there are errors they won't go away when you click clear. So you can click the error (always start with the top most) and then you can select the error text in the bottom half of the console to copy it:
Your answer
![](https://koobas.hobune.stream/wayback/20220613120257im_/https://answers.unity.com/themes/thub/images/avi.jpg)