Error with all c# scripts (FIXED!)

I am trying to create a top-down rpg in the most recent version of unity. I wrote a couple scripts, but they all got the script class could not be found error. I have tried multiple tutorials, ect… but they all still get the error. please help!
Player script:

using UnityEngine;
using System.Collections;

public class Player: Entity
{

    void Start()
    {

    }

    void Update()
    {
        if (Input.getkey(keycode.w) || Input.getkey(keycode.UpArrow))
        {
            rigidbody2d.transform.position += Vector3.up * speed * Time.deltaTime;
        }
        if (Input.getkey(keycode.a) || Input.getkey(keycode.RightArrow))
        {
            rigidbody2d.transform.position += Vector3.right * speed * Time.deltaTime;
        }
        if (Input.getkey(keycode.s) || Input.getkey(keycode.DownArrow))
        {
            rigidbody2d.transform.position += Vector3.down * speed * Time.deltaTime;
        }
        if (Input.getkey(keycode.d) || Input.getkey(keycode.LeftArrow))
        {
            rigidbody2d.transform.position += Vector3.left * speed * Time.deltaTime;
        }
    }

}

Entity script:

using UnityEngine;
using System.Collections;

public abstract class Entity: MonoBehaviour {

    public float speed;

    void Start() {
      
    }


    void Update()
    {
}}

And, yes I did check to make sure the names match. That was what all the tutorials said to do.

What is the actual error message? Line number?

1 Like

It happens when I try to drag the script into the player object. The unity error name is “can’t add script”. In visual studio, the debugger tells me that there is nothing wrong with the code.

Do you have compiler errors in the console?

Right off the bat i see you have Input.getkey which should be Input.GetKey, which would cause your script not to compile.

1 Like

Well, I just fixed it and am still getting the error. are there any other issues that you can spot?

The console will tell you what the problems are. Can you copy and paste the actual error messages with the file name and line number? The “cant add script” is most likely just a symptom of your code having compiler errors.

So, my issue is that the console is displaying no errors. Also, I managed to fix the player script, now I just need help weeding out issues with the entity script. As the player script is dependent on the entity script, It will not work properly without it.

nvmd, I figured it out.

My guess would be that you have the Player script on the player and Entity should be on your player because it’s a MonoBehavior. Also just noticed that you have resolved this issue. Always a good idea to share your solution in case someone else runs into the issue and searches bring them to your thread.

Thank you for the help, but the issue has been resolved.