Code coming up with error saying no Monobehaviour scripts in the file

So I have made a script & saved it but whenever I try to add it to my object it just says “must fix all compile errors” or something like that. If I click on the script it comes up with “No monobehaviour scripts in this file, or their names do not match the file name.”

I have searched all over the forums but I have found NOTHING that works

Someone please help! :frowning:

K sorry 4 the late reply, I have tried some stuff since then but my code is still not working, here it is:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour {

		public float speed;

		private Rigidbody rb;

		void Start()
		{
			rb = GetComponent<Rigidbody>();
		}

		void FixedUpdate()
		{
			float moveHorizontal = Input.GetAxis("Horizontal");
			float moveVertical = Input.GetAxis("Vertical");

			Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);

			rb.AddForce(movement * speed); Material
		} /* <-- This is where it tells me I need a ';' */

}

& BTW I have checked my console & it says it is expecting a ; right next to the closing bracket of FixedUpdate.

@CoolOlivie
Simple problem. You had a class call right next to the line:

rb.AddForce(movement * speed); Material

To fix the problem we delete that class call. Material is part of the component Renderer. Now it should work fine.

using System.Collections; 
using System.Collections.Generic; 
using UnityEngine;

public class PlayerController : MonoBehaviour {

         public float speed;
         private Rigidbody rb;

         void Start()
         {
             rb = GetComponent<Rigidbody>();
         }

         void FixedUpdate()
         {
             float moveHorizontal = Input.GetAxis("Horizontal");
             float moveVertical = Input.GetAxis("Vertical");
             Vector3 movement = new Vector3(moveHorizontal, 0.0f, moveVertical);
             rb.AddForce(movement * speed);
         } 
}