Why doesn't this movement script work?

Recently I’ve been trying to create a script to move the player from left and right. I’ve assigned everything in the editor, and added a considerable amount of force, but when I play and press the keys the player is not moving. I’ve asked several other people, and no one has been able to help me. Why is this not working?

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

public class Movement : MonoBehaviour
{
    public Rigidbody rb;

    public float MoveSpeed;

    public float JumpSpeed = 9999f;

    public bool JumpCheck;

    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent<Rigidbody>();

        JumpCheck = GetComponent<CheckIfJump>();
    }

    // Update is called once per frame
    void FixedUpdate()
    {
        if (Input.GetKey(KeyCode.RightArrow))
        {
            rb.AddForce(Vector3.right * JumpSpeed * Time.deltaTime);
        }

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            rb.AddForce(Vector3.left * JumpSpeed * Time.deltaTime);
        }

        if (Input.GetKey(KeyCode.Z) && JumpCheck == true)
        {
            rb.AddForce(transform.up * JumpSpeed * Time.deltaTime);
        }
        Debug.Log(rb.velocity);
    }


}

hey @TooManyPixelz,

It seems to be working fine, yes it moves at an incredible speed but it seems to be working fine.
I did remove the JumpCheck = GetComponent<CheckIfJump>(); as i didn’t have that script, i recommend removing that line of code and trying again

Also make sure “Is Kinematic” is set to false

Your rigidbody is likely kinematic.

I would also recommend using GetAxis and rigidbody.velocity instead of GetKey and AddForce respectively.

Vector3 vx = transform.forward * GetAxis("Vertical");
Vector3 vz = transform.right * GetAxis("Horizontal");
Vector3 velocity = vx + vz;
velocity.z = 0;
velocity = ClampMagnitude(velocity, 1f) * MoveSpeed;

velocity.y = rigidbody.velocity.y;
if (Input.GetKey(KeyCode.Z) && JumpCheck == true)
    velocity.y += JumpSpeed;
rigidbody.velocity = velocity;

Here we transform the input axis into a vector, remove the vertical component, limit its length to 1, multiply it by your movement speed, then keep the old vertical speed.

If you want to jump, simply add to the vertical velocity.