Player Movement Not Working

My script for moving the player is not working. I have looked for red lines but everything looks good, however, when I play the game, the player is instantly stuck moving towards positive X. Here is the script:

using UnityEngine;

public class PlayerController : MonoBehaviour {

    public GameObject pBody;
    public GameObject pGunOrigin;
	public static float speed;
    Vector3 gOffset;
	void Start () {
        gOffset = pGunOrigin.transform.position - transform.position;
        GetComponent<Rigidbody>().velocity = new Vector3(0, 0, 0);
    }
	void FixedUpdate () {
        if (Input.GetKey(KeyCode.RightArrow))
        {
            GetComponent<Rigidbody>().velocity = new Vector3(speed, GetComponent<Rigidbody>().velocity.y, GetComponent<Rigidbody>().velocity.z);
        }
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            GetComponent<Rigidbody>().velocity = new Vector3(-speed, GetComponent<Rigidbody>().velocity.y, GetComponent<Rigidbody>().velocity.z);
        }
        if (Input.GetKey(KeyCode.UpArrow))
        {
            GetComponent<Rigidbody>().velocity = new Vector3(GetComponent<Rigidbody>().velocity.x, GetComponent<Rigidbody>().velocity.y, speed);
        }
        if (Input.GetKey(KeyCode.DownArrow))
        {
            GetComponent<Rigidbody>().velocity = new Vector3(GetComponent<Rigidbody>().velocity.x, GetComponent<Rigidbody>().velocity.y, -speed);
        }
        if (Input.GetKey(KeyCode.DownArrow) == false && Input.GetKey(KeyCode.UpArrow) == false && Input.GetKey(KeyCode.RightArrow) == false && Input.GetKey(KeyCode.LeftArrow) == false)
        {
            GetComponent<Rigidbody>().velocity = new Vector3(0, 0, 0);
        }
        pGunOrigin.transform.position = pBody.transform.position + gOffset;
    }
}

What’s wrong?

Is this probably a physics reaction? If your gun and player (which are seemingly not part of the same hierarchy as you explicitly fix their relative position by code) both have colliders, the player may be pushed away by colliding with the gun.

If that is the case you could disable the collision between those two by using Physics.IgnoreCollision() or by using the physics layer configuration.

PS: You should probably also have a look at Input.GetAxis().