a player moves with both keys, then vice versa what should i do

i have two seperate scripts, ones for player 1 the second is for player 2, player 1moves with the w-a-s-d, and 2 uses arrow keys, when i controll 1 with w-a-s-d and i use the arrow keys as well player 1 moves via the arrow keys idk why, those are the scripts, any help would be appreciated:

player 1:

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

public class Player1 : MonoBehaviour
{

//note bien:
// buttons: space: jump, w-a-s-d, e cam, left shift: megajump

//Other
private Rigidbody rb;
public Camera[] cams;
public int camCounter = 0;

//Rotation and look
private float xRotation;
private float sensitivity = 50f;
private float sensMultiplier = 1f;

//Movement
public float moveSpeed = 4500;
public float maxSpeed = 20;
public bool grounded;
public bool megaJumpReady;
public LayerMask whatIsGround;

public float counterMovement = 0.175f;
private float threshold = 0.01f;
public float maxSlopeAngle = 35f;

//Crouch & Slide
private Vector3 crouchScale = new Vector3(1, 0.5f, 1);
private Vector3 playerScale;
public float slideForce = 400;
public float slideCounterMovement = 0.2f;

//Jumping
private bool readyToJump = true;
private float jumpCooldown = 0.25f;
public float jumpForce = 550f;

//Input
float x, y;
bool jumping, sprinting;

//Sliding
private Vector3 normalVector = Vector3.up;
private Vector3 wallNormalVector;

void Awake()
{
    rb = GetComponent<Rigidbody>();
}

void Start()
{
    playerScale = transform.localScale;
    Cursor.lockState = CursorLockMode.Locked;
    Cursor.visible = false;
}

private void FixedUpdate()
{
    Movement();
    megaJumping();
}

private void Update()
{
    CamThing();
    MyInput();
}

/// <summary>
/// Find user input. Should put this in its own class but im lazy
/// </summary>
private void MyInput()
{
    if (Input.GetKey(KeyCode.D))
        x = +1;
    if (Input.GetKey(KeyCode.A))
        x = -1;
    if (Input.GetKey(KeyCode.W))
        y = +1;
    if (Input.GetKey(KeyCode.S))
        y = -1;

    jumping = Input.GetKey(KeyCode.Space);

}

private void StartCrouch()
{
    transform.localScale = crouchScale;
    transform.position = new Vector3(transform.position.x, transform.position.y - 0.5f, transform.position.z);
    if (rb.velocity.magnitude > 0.5f)
    {
        if (grounded)
        {
            rb.AddForce(transform.forward * slideForce);
        }
    }
}

private void StopCrouch()
{
    transform.localScale = playerScale;
    transform.position = new Vector3(transform.position.x, transform.position.y + 0.5f, transform.position.z);
}

private void Movement()
{
    //Extra gravity
    rb.AddForce(Vector3.down * Time.deltaTime * 10);

    //Find actual velocity relative to where player is looking
    Vector2 mag = FindVelRelativeToLook();
    float xMag = mag.x, yMag = mag.y;

    //Counteract sliding and sloppy movement
    CounterMovement(x, y, mag);

    //If holding jump && ready to jump, then jump
    if (readyToJump && jumping) Jump();

    //Set max speed
    float maxSpeed = this.maxSpeed;

    //If speed is larger than maxspeed, cancel out the input so you don't go over max speed
    if (x > 0 && xMag > maxSpeed) x = 0;
    if (x < 0 && xMag < -maxSpeed) x = 0;
    if (y > 0 && yMag > maxSpeed) y = 0;
    if (y < 0 && yMag < -maxSpeed) y = 0;

    //Some multipliers
    float multiplier = 1f, multiplierV = 1f;

    // Movement in air
    if (!grounded)
    {
        multiplier = 0.5f;
        multiplierV = 0.5f;
    }

    //Apply forces to move player
    rb.AddForce(transform.forward * y * moveSpeed * Time.deltaTime * multiplier * multiplierV);
    rb.AddForce(transform.right * x * moveSpeed * Time.deltaTime * multiplier);
    x = 0;
    y = 0;
}

private void Jump()
{
    if (grounded && readyToJump)
    {
        readyToJump = false;

        //Add jump forces
        rb.AddForce(Vector2.up * jumpForce * 1.5f);
        rb.AddForce(normalVector * jumpForce * 0.5f);

        //If jumping while falling, reset y velocity.
        Vector3 vel = rb.velocity;
        if (rb.velocity.y < 0.5f)
            rb.velocity = new Vector3(vel.x, 0, vel.z);
        else if (rb.velocity.y > 0)
            rb.velocity = new Vector3(vel.x, vel.y / 2, vel.z);

        Invoke(nameof(ResetJump), jumpCooldown);
    }
}

private void ResetJump()
{
    readyToJump = true;
}

private float desiredX;

private void CounterMovement(float x, float y, Vector2 mag)
{
    if (!grounded || jumping) return;

    //Counter movement
    if (Math.Abs(mag.x) > threshold && Math.Abs(x) < 0.05f || (mag.x < -threshold && x > 0) || (mag.x > threshold && x < 0))
    {
        rb.AddForce(moveSpeed * transform.right * Time.deltaTime * -mag.x * counterMovement);
    }
    if (Math.Abs(mag.y) > threshold && Math.Abs(y) < 0.05f || (mag.y < -threshold && y > 0) || (mag.y > threshold && y < 0))
    {
        rb.AddForce(moveSpeed * transform.forward * Time.deltaTime * -mag.y * counterMovement);
    }

    //Limit diagonal running. This will also cause a full stop if sliding fast and un-crouching, so not optimal.
    if (Mathf.Sqrt((Mathf.Pow(rb.velocity.x, 2) + Mathf.Pow(rb.velocity.z, 2))) > maxSpeed)
    {
        float fallspeed = rb.velocity.y;
        Vector3 n = rb.velocity.normalized * maxSpeed;
        rb.velocity = new Vector3(n.x, fallspeed, n.z);
    }
}

/// <summary>
/// Find the velocity relative to where the player is looking
/// Useful for vectors calculations regarding movement and limiting movement
/// </summary>
/// <returns></returns>
public Vector2 FindVelRelativeToLook()
{
    float lookAngle = transform.eulerAngles.y;
    float moveAngle = Mathf.Atan2(rb.velocity.x, rb.velocity.z) * Mathf.Rad2Deg;

    float u = Mathf.DeltaAngle(lookAngle, moveAngle);
    float v = 90 - u;

    float magnitue = rb.velocity.magnitude;
    float yMag = magnitue * Mathf.Cos(u * Mathf.Deg2Rad);
    float xMag = magnitue * Mathf.Cos(v * Mathf.Deg2Rad);

    return new Vector2(xMag, yMag);
}

private bool IsFloor(Vector3 v)
{
    float angle = Vector3.Angle(Vector3.up, v);
    return angle < maxSlopeAngle;
}

private bool cancellingGrounded;

/// <summary>
/// Handle ground detection
/// </summary>
private void OnCollisionStay(Collision other)
{
    //Make sure we are only checking for walkable layers
    int layer = other.gameObject.layer;
    if (whatIsGround != (whatIsGround | (1 << layer))) return;

    //Iterate through every collision in a physics update
    for (int i = 0; i < other.contactCount; i++)
    {
        Vector3 normal = other.contacts*.normal;*

//FLOOR
if (IsFloor(normal))
{
grounded = true;
cancellingGrounded = false;
normalVector = normal;
CancelInvoke(nameof(StopGrounded));
}
}
//Invoke ground/wall cancel, since we can’t check normals with CollisionExit
float delay = 3f;
if (!cancellingGrounded)
{
cancellingGrounded = true;
Invoke(nameof(StopGrounded), Time.deltaTime * delay);
}
}
private void CamThing()
{

if (Input.GetKeyDown(KeyCode.E))
{

camCounter++;
if (camCounter == cams.Length)
{
camCounter = 0;
}
for (int i = 0; i < cams.Length; i++)
{
cams*.gameObject.SetActive(false);*
}
cams[camCounter].gameObject.SetActive(true);
}
}
private void StopGrounded()
{
grounded = false;
}
private void megaJumping()
{
if (megaJumpReady)
{
if (Input.GetKeyDown(KeyCode.LeftShift))
{
megaJumpReady = false;
StartCoroutine(megaJumpReset());
rb.AddForce(transform.up * jumpForce * 4);
}
}
}
IEnumerator megaJumpReset()
{
yield return new WaitForSeconds(5f);
megaJumpReady = true;
}
}
and player 2:
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
public class Player2 : MonoBehaviour
{

//note bien:
// buttons: left mouse button: jump, arrows, middle mouse button cam, right mouse button: megajump
//Other
private Rigidbody rb;
public Camera[] cams;
public int camCounter = 0;
//Rotation and look
private float xRotation;
private float sensitivity = 50f;
private float sensMultiplier = 1f;
//Movement
public float moveSpeed = 4500;
public float maxSpeed = 20;
public bool grounded;
public bool megaJumpReady;
public LayerMask whatIsGround;
public float counterMovement = 0.175f;
private float threshold = 0.01f;
public float maxSlopeAngle = 35f;
//Crouch & Slide
private Vector3 crouchScale = new Vector3(1, 0.5f, 1);
private Vector3 playerScale;
public float slideForce = 400;
public float slideCounterMovement = 0.2f;
//Jumping
private bool readyToJump = true;
private float jumpCooldown = 0.25f;
public float jumpForce = 550f;
//Input
float x, y;
bool jumping, sprinting;
//Sliding
private Vector3 normalVector = Vector3.up;
private Vector3 wallNormalVector;
void Awake()
{
rb = GetComponent();
}
void Start()
{
playerScale = transform.localScale;
Cursor.lockState = CursorLockMode.Locked;
Cursor.visible = false;
}
private void FixedUpdate()
{
Movement();
megaJumping();
}
private void Update()
{
CamThing();
MyInput();
}
///


/// Find user input. Should put this in its own class but im lazy
///

private void MyInput()
{
if (Input.GetKey(KeyCode.RightArrow))
x = +1;
if (Input.GetKey(KeyCode.LeftArrow))
x = -1;
if (Input.GetKey(KeyCode.UpArrow))
y = +1;
if (Input.GetKey(KeyCode.DownArrow))
y = -1;
jumping = Input.GetMouseButton(0);
}
private void StartCrouch()
{
transform.localScale = crouchScale;
transform.position = new Vector3(transform.position.x, transform.position.y - 0.5f, transform.position.z);
if (rb.velocity.magnitude > 0.5f)
{
if (grounded)
{
rb.AddForce(transform.forward * slideForce);
}
}
}
private void StopCrouch()
{
transform.localScale = playerScale;
transform.position = new Vector3(transform.position.x, transform.position.y + 0.5f, transform.position.z);
}
private void Movement()
{
//Extra gravity
rb.AddForce(Vector3.down * Time.deltaTime * 10);
//Find actual velocity relative to where player is looking
Vector2 mag = FindVelRelativeToLook();
float xMag = mag.x, yMag = mag.y;
//Counteract sliding and sloppy movement
CounterMovement(x, y, mag);
//If holding jump && ready to jump, then jump
if (readyToJump && jumping) Jump();
//Set max speed
float maxSpeed = this.maxSpeed;
//If speed is larger than maxspeed, cancel out the input so you don’t go over max speed
if (x > 0 && xMag > maxSpeed) x = 0;
if (x < 0 && xMag < -maxSpeed) x = 0;
if (y > 0 && yMag > maxSpeed) y = 0;
if (y < 0 && yMag < -maxSpeed) y = 0;
//Some multipliers
float multiplier = 1f, multiplierV = 1f;
// Movement in air
if (!grounded)
{
multiplier = 0.5f;
multiplierV = 0.5f;
}
//Apply forces to move player
rb.AddForce(transform.forward * y * moveSpeed * Time.deltaTime * multiplier * multiplierV);
rb.AddForce(transform.right * x * moveSpeed * Time.deltaTime * multiplier);
x = 0;
y = 0;
}
private void Jump()
{
if (grounded && readyToJump)
{
readyToJump = false;
//Add jump forces
rb.AddForce(Vector2.up * jumpForce * 1.5f);
rb.AddForce(normalVector * jumpForce * 0.5f);
//If jumping while falling, reset y velocity.
Vector3 vel = rb.velocity;
if (rb.velocity.y < 0.5f)
rb.velocity = new Vector3(vel.x, 0, vel.z);
else if (rb.velocity.y > 0)
rb.velocity = new Vector3(vel.x, vel.y / 2, vel.z);
Invoke(nameof(ResetJump), jumpCooldown);
}
}
private void ResetJump()
{
readyToJump = true;
}
private float desiredX;
private void CounterMovement(float x, float y, Vector2 mag)
{
if (!grounded || jumping) return;
//Counter movement
if (Math.Abs(mag.x) > threshold && Math.Abs(x) < 0.05f || (mag.x < -threshold && x > 0) || (mag.x > threshold && x < 0))
{
rb.AddForce(moveSpeed * transform.right * Time.deltaTime * -mag.x * counterMovement);
}
if (Math.Abs(mag.y) > threshold && Math.Abs(y) < 0.05f || (mag.y < -threshold && y > 0) || (mag.y > threshold && y < 0))
{
rb.AddForce(moveSpeed * transform.forward * Time.deltaTime * -mag.y * counterMovement);
}
//Limit diagonal running. This will also cause a full stop if sliding fast and un-crouching, so not optimal.
if (Mathf.Sqrt((Mathf.Pow(rb.velocity.x, 2) + Mathf.Pow(rb.velocity.z, 2))) > maxSpeed)
{
float fallspeed = rb.velocity.y;
Vector3 n = rb.velocity.normalized * maxSpeed;
rb.velocity = new Vector3(n.x, fallspeed, n.z);
}
}
///
/// Find the velocity relative to where the player is looking
/// Useful for vectors calculations regarding movement and limiting movement
///

///
public Vector2 FindVelRelativeToLook()
{
float lookAngle = transform.eulerAngles.y;
float moveAngle = Mathf.Atan2(rb.velocity.x, rb.velocity.z) * Mathf.Rad2Deg;
float u = Mathf.DeltaAngle(lookAngle, moveAngle);
float v = 90 - u;
float magnitue = rb.velocity.magnitude;
float yMag = magnitue * Mathf.Cos(u * Mathf.Deg2Rad);
float xMag = magnitue * Mathf.Cos(v * Mathf.Deg2Rad);
return new Vector2(xMag, yMag);
}
private bool IsFloor(Vector3 v)
{
float angle = Vector3.Angle(Vector3.up, v);
return angle < maxSlopeAngle;
}
private bool cancellingGrounded;
///
/// Handle ground detection
///

private void OnCollisionStay(Collision other)
{
//Make sure we are only checking for walkable layers
int layer = other.gameObject.layer;
if (whatIsGround != (whatIsGround | (1 << layer))) return;
//Iterate through every collision in a physics update
for (int i = 0; i < other.contactCount; i++)
{
Vector3 normal = other.contacts*.normal;*
//FLOOR
if (IsFloor(normal))
{
grounded = true;
cancellingGrounded = false;
normalVector = normal;
CancelInvoke(nameof(StopGrounded));
}
}
//Invoke ground/wall cancel, since we can’t check normals with CollisionExit
float delay = 3f;
if (!cancellingGrounded)
{
cancellingGrounded = true;
Invoke(nameof(StopGrounded), Time.deltaTime * delay);
}
}
private void CamThing()
{

if (Input.GetMouseButtonDown(2))
{

camCounter++;
if (camCounter == cams.Length)
{
camCounter = 0;
}
for (int i = 0; i < cams.Length; i++)
{
cams*.gameObject.SetActive(false);*
}
cams[camCounter].gameObject.SetActive(true);
}
}
private void StopGrounded()
{
grounded = false;
}
private void megaJumping()
{
if (megaJumpReady)
{
if (Input.GetMouseButton(1))
{
megaJumpReady = false;
StartCoroutine(megaJumpReset());
rb.AddForce(transform.up * jumpForce * 4);
}
}
}
IEnumerator megaJumpReset()
{
yield return new WaitForSeconds(5f);
megaJumpReady = true;
}
}
if you managed to find this post and help me thanks a lot

Almost sounds like you have both scripts attached to the same Player object.
Try putting a Debug.Log(“Player One Move”); in the MyInput method and a different message in the other script.