Monobehaviour script's location

I’m at 8:10 in this tutorial it tells me "No Monobehaviour scripts in the file or their names do not match the file name. " I’m pretty sure the file names match because I’m following this tutorial pretty closely and my file names and class names match. Which means I probably have the Monobehaviour script’s location to blame.Any ideas?

No idea without screenshots and scripts.

Common mistake to overlook is not UK-spelling the word “behaviour”. In your post above you use a lowercase B in Monobehaviour. The class names mentioned such as MonoBehaviour must be identical and match upper/lower-case usage. The filename and the class name you’re defining must be identical, and case-matching is preferred (and required on some platforms).

Sorry, here you go:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class BackgroundHolder : MonoBehaviour
{
    public Transform BG1, BG2;
    public float scrollSpeed;
    public float bgWidth;
    // Start is called before the first frame update
    void Start()
    {
        bgWidth = BG1.GetComponent<SpriteRenderer>().sprite.bounds.size.x;
    }
    // Update is called once per frame
    void Update()
    {
  
    }
}

I wonder if some part of the system is confused by the lack of newline after the using UnityEngine; part, or assumes the class keyword to be at the beginning of a line. It’s valid C# but something in Unity is complaining. Sometimes system checkers make some quick assumptions rather than go through a more rigorous parsing step.

But there’s a linebreak in the screenshot. Hrmmm.

The Script called BackgroundScroller.cs but you have a BackgroundHolder class in it. Change it to match. See your own screenshot.

I’m pretty sure the solution worked! Thank you a lot!