2D Walking Script Help

So I have this walking script that when I press A it does a animation and walks to the left and same thing for the D, but if I press both of them at the same time it does the animation but doesnt move, is there a way to make the player walk to the direction that was pressed last?

example: press A and it goes left and when pressed D also and it goes to the right

like in pokemon :stuck_out_tongue:

You want to respond to the key that was pressed last, right? Just keep track of when each key was pressed, so that if they are both down, you know which one was last. Input.GetKeyDown should help you with knowing when the key is pressed. When that happens, save the current time to a class-level variable maybe called leftDownTime or rightDownTime.