Unity Local Co op not working.,I am trying to do local co op in unity with 2 gamepads but both players are moving according to one gamepad.

When I start my game both gamepads can spawn in a player by them self but if I move on one gamepad both players move. This can be done with both gamepads. I move on one it moves both players as one.,When I start the game it works normally and you can spawn in two players using each gamepad by them self but the players move together as one game object. Both gamepads move the players together.

Your script reading the input from the gamepad will somehow need to know if it is Player #1 or Player #2 and move that player.
It depends on how your code is written. There is no simple answer, you need to add code to know which player it is and then assign a variable so it points to the right player on the screen.

A suggestion would be to create a second game object with another copy of your input script, and have a simple integer variable of 1 or 2 so that in your code you can look at the 1 or 2 and make more decisions later in your code when needed.
So you currently probably have one script attached to the player’s gameobject, for reading the gamepad input and it moves that object around possibly. I am saying that when you create the second player’s gameobject, it will also have the same input script attached and it should move the second player without any changes, since your code should just use “transform.” and other operations within the current gameobject context and not refer to external references from the gameobject. The only change you need to make is to set the player number variable to 1 or 2, and then have an IF statement to check that number and read input from controller #1 or input from controller #2.
So you would end up with two scripts on different player gameobjects, the first one would have it’s PlayerNumber variable set to 1 and the second player’s gameobject input script would have PlayerNumber set to 2.

Here is a tutorial using the New Input System, which I recommend because it has features specifically for local couch multiplayer: