Assets\Scripts\NewBehaviourScript.cs(5,6): error CS0116: A namespace cannot directly contain members

So im new to unity and my code has an error that i can’t fix , any help ?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
void Update()
{
if (Input.GetKey(KeyCode.LeftArrow)) ;
{
transform.position += Vector3.left * speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.RightArrow))
{
transform.position += Vector3.right * speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.UpArrow))
{
transform.position += Vector3.up * speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.DownArrow))
{
transform.position += Vector3.down * speed * Time.deltaTime;
}
}

it looks like you have a semicolon in the line of your first if statement, here :

if (Input.GetKey(KeyCode.LeftArrow)) ;

I believe that is an error.

other than that I’d have to open Unity to see how the movement runs. I’ll do so if you still have problems with it, but try removing that semicolon first. As you did not put the semicolons in the other if lines, it looks like it was just a typo. Those happen.

You forgot to put your code inside a class. Try creating a new script from within Unity and it should setup the right boilerplate for you.