Need some help with my code

I am trying to make a simple movement script with jumping in c# but ik keep getting this error and don’t know what to do:
Assets\Scripts\PlayerMovement.cs(4,11): error CS0116: A namespace cannot directly contain members such as fields or methods

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
Rigidbody rb;

public class PlayerMovement : MonoBehaviour
{
    Rigidbody rb;
    
    void Start()
    {
        rb = GetComponent<Rigidbody>();
    }

    float movementSpeed;
    
    void Update()
    {
        float amountToMove = movementSpeed * Time.deltaTime;
        Vector3 movement = (Input.GetAxis("Horizontal") * -Vector3.left * amountToMove) + (Input.GetAxis("Vertical") * Vector3.forward * amountToMove);
        rb.AddForce(movement, ForceMode.Force);

        if (Input.GetKeyDown("space"))
        {
            rb.AddForce(Vector3.up * jumpSpeed);
        }


    }

    void OnCollisionStay()
    {
        onGround = true;
    }


    [SerializeField]
    Vector3 v3Force;

    [SerializeField]
    KeyCode keyPositive;
    [SerializeField]
    KeyCode keyNegative;
 

    void FixedUpdate()
    {
        if (Input.GetKey(keyPositive))
            GetComponent<Rigidbody>().velocity += v3Force;

        if (Input.GetKey(keyNegative))
            GetComponent<Rigidbody>().velocity -= v3Force;
    }
}

So, nice thing about errors is it tells you usually where or about where it is having issues. In this case, line 4.

Line 4 shows a Rigidbody rb; variable declaration…but it’s up within your using statements. Essentially you are declaring a variable outside of a class. Yet, you have the same variable declaration in the class. Not sure what you were going for.

The fix? Delete line 4.