The script needs to derive from MonoBehavior?

Hello there…
I have, yet again, a huge problem. I had some troubles with the Gravestone script.
It all started with an Error:

You are trying to replace or create a prefab from the instance ‘Gravestone’ that contains the script ‘Health’, which is does not derive from MonoBehavior. This is not allowed.
Please change the script to derive from MonoBehavior or remove it from the game object.
UnityEditorInternal.InternalEditorUtility:ProjectWindowDrag(HierarchyProperty, Boolean)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

So I deleted the script, created a new one, but still the same, i restarted Unity and then the troubles began!

So my Problem is, every script in my Project has now this Error of MonoBehavior.

-What caused this?
-How can I prevent this?
-And how can i reset my Project? (I tried to make a hard reset with sourcetree, but that didn’t work either…)

If somebody had the same Probelm and a Solution for it, I would appreciate help.

Can you post your Health.cs script Dominik, and apply code formatting please.

1 Like

I could fix it in the meantime, but still do not know why…
I didn’t change anything in the Health.cs, but deleted the Fox.cs and wrote it from scratch (I did not copy it from the Lizard, like in the course)

Sooo… it works now… and because there is no real solution, I think you can delete the post if you want :slight_smile:

Hi,

Glad to hear you’ve resolved the problem.

Errors can often cascade, one thing causes another and so on.

The specific error message can often be attributed to the class name and the script name not being the same. Obviously without being able to see the issue it’s hard to say now.

Again, glad you’ve resolved the problem and can move on :slight_smile:

1 Like

That was the fist thing I checked. I searched some forums first, including gamedev.tv, where a similiar post of the same problem was.

Thanks again
And I hope see you not to soon again :smiley:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms