“the script needs to derive from monobehaviour”

Hello, can people please let me know why the below error message keeps poping up?

“the script needs to derive from monobehaviour”

My code is as below was completed by Github Capilot, I have no idea how can I fix this and I’m stuck here

strong textusing UnityEngine;
using System.Collections;
using system.Collections.Generic;

public class Collectible_heart: MonoBehaviour
{
    
}

Thanks a mill!

For one of the many reasons listed as replies in the thread you’ve linked to.

I have compiled my own list that you can go through:
Resolving script loading issues.

1 Like

Oh my God it’s fixed! You are a genius thank you I’ve been stuck here for the past 3 days.

Can I ask you a follow up question? - I’m not sure how to clear the below message. The script with the right object’s name was deleted earlier but I created another script with the same name. Now I’m getting two wanings below - does it matter? do I need to solve them now?

Assets_Unity Essentials\Source Files\Scripts\UpdateCollectibleCount.cs(33,34): warning CS0618: ‘Object.FindObjectsOfType(Type)’ is obsolete: ‘Object.FindObjectsOfType has been deprecated. Use Object.FindObjectsByType instead which lets you decide whether you need the results sorted or not. FindObjectsOfType sorts the results by InstanceID, but if you do not need this using FindObjectSortMode.None is considerably faster.’

On line 33 of UpdateCollectibleCount, in the Unity Essentials source files, change FindObjectsOfType to FindObjectsByType(FindObjectSortMode.None).

1 Like