Error building Player because scripts had compiler errors in the editor (Without The Editor Script)

I keep getting the error (Error building player because scripts had compiler errors in the editor. this is what my code looks like (p.s. it’s probably obviously wrong to all of you but I just started this week)

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

public class PlayerMovement : MonoBehaviour
{
public float moveSpeed;
public Rigidbody2D rb;
private Vector2 moveDirection;

// Update is called once per frame
void Update()
{

}

private void FixedUpdate()
{
Vector2 vector2 = new Vector2(moveDirectiion.x * moveSpeed, moveDirection.y * moveSpeed);
rb.velocity = vector2;
}

void ProcessInputs()
{
float moveX = Input.GetAxisRaw(“Horizontal”);
float moveY = Input.GetAxisRaw(“Vertical”);

moveDirection = new Vector2(moveX, moveY);
}
}
}

Firstly, don’t post pictures of your code, it’s pointless. Secondly use Code tags, see this: Using code tags properly

What is your error. Go into the editor then console to see what the error is. In the code screenshot you put here. I can see that moveDirection is underlined in red. Meaning there is an error. Please show us the error

versus

1 Like

It says that moveDirection does not exist in the current context (Edit) there was one typo lets see if this works

Now ive got a directory not found exception when trying to build and if i try to run the game within unity it says that Rb is not assigned even though i assigned it in the inspector like it said. I know it’s probably something small that will clear up fast

And here is how! You can do it!

Remember: NOBODY memorizes error codes. The error code is absolutely the least useful part of the error. It serves no purpose at all. Forget the error code. Put it out of your mind.

The important parts of an error message are:

  • the description of the error itself (google this; you are NEVER the first one!)
  • the file it occurred in (critical!)
  • the line number and character position (the two numbers in parentheses)

All of that information is in the actual error message and you must pay attention to it. Learn how to identify it instantly so you don’t have to stop your progress and fiddle around with the forum.

How to understand compiler and other errors and even fix them yourself:

https://discussions.unity.com/t/824586/8

If you post a code snippet, ALWAYS USE CODE TAGS:

How to use code tags: https://discussions.unity.com/t/481379