I keep getting the 'the script don't inherit a ntive class that can manage a script'

I keep getting the ‘the script don’t inherit a ntive class that can manage a script’ when I drag my script to an object
The code is here
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LevelController : MonoBehaviour
{
Monster[ ] monsters;

[SerializeField] string nextLevelName;

void OnEnable()
{
monsters = FindObjectsOfType();
}

// Update is called once per frame
void Update()
{
if (MonstersAreAllDead())
GoToNextLevel();
}

void GoToNextLevel()
{
Debug.Log("Go to Level " + nextLevelName);
}

bool MonstersAreAllDead()
{
foreach (var monster in monsters)
{
if (monster.gameObject.activeSelf)
return false;
}
return true;
}
}

What’s the name of this file?
Do you have any other errors in your console?

I have fixed all other errors and the name of the file is Level Controller.cs

If the filename has a space, that’s your problem. It must match 100% in spelling and capitalization when it is a MonoBehaviour.

1 Like

It works
Thanks

1 Like