Player 1 and Player 2 move together

I have a separate script for player 1 and player 2, but they act like they are both interpreting the same controls from my one controller. When I take the P2 script off the second character, player 2 will not move. If I take the Player 1 script off of player 1, player 2 still moves.

Here is my Player 1 script:

 // Determine the angle of the left thumbstick
 var xAxis = Input.GetAxis("L_XAxis_1");
 var yAxis = Input.GetAxis("L_YAxis_1");
 
 //reset rotation so rigidbodies don't get flipped
 transform.rotation = Quaternion.identity;
 
 //find the target to move towards
 var xtarget = transform.position.x + xAxis;
 var ytarget = transform.position.y + yAxis;
 var target = Vector3(xtarget, ytarget, 0);
 
 // The step size is equal to speed times frame time.
 //This finds how hard the player is pushing the joystick, and changes speed
 speed = Vector2(xAxis, yAxis).magnitude * 4 ;
 var step = speed * Time.deltaTime;
 
 // Move our position a step closer to the target.
 transform.position = Vector3.MoveTowards(transform.position, target, step);

And here is my Player 2 script:

 // Determine the angle of the left thumbstick
 var xAxis = Input.GetAxis("L_XAxis_2");
 var yAxis = Input.GetAxis("L_YAxis_2");
 
 //reset rotation so rigidbodies don't get flipped
 transform.rotation = Quaternion.identity;
 
 //find the target to move towards
 var xtarget = transform.position.x + xAxis;
 var ytarget = transform.position.y + yAxis;
 var target = Vector3(xtarget, ytarget, 0);
 
 // The step size is equal to speed times frame time.
 //This finds how hard the player is pushing the joystick, and changes speed
 speed = Vector2(xAxis, yAxis).magnitude * 4 ;
 var step = speed * Time.deltaTime;
 
 // Move our position a step closer to the target.
 transform.position = Vector3.MoveTowards(transform.position, target, step);

Here is the input for movement (only showed left x axis, because it’s a big picture):

input

Here is the player 1 gameobject:

player1

And here is the player 2 gameobject:

player2

Do you see where the problem might be? My controller seems to work fine.

try putting the p1 script on an empty game object and instead of saying
transform.position = Vector3.MoveTowards(transform.position, target, step);

cache the two players and move whichever u fell like moving…

here both players move coz , i guess u r calling this code in the update and both updates would get called…