I am assuming that you are using Conner’s tutorial on VEX PID. I think your problem is that you copied it straight, but forgot to read his comment after.
" Fair Warning: I am unsure if I have the positive and negative motor values correct, as this is all done on the top of my head. So If the robot is continuing to go even after the lateral position is reached, change
error = averagePosition - desiredValue;
to
error = desiredValue - averagePosition;
If the robot continues to go even after the turning desired is reached, change
turnError = turnDifference - desiredTurnValue;
to
turnError = desiredTurnValue - turnDifference;
Helpful information:
If you need any further clarification, respond below and I can answer
"
ref: https://www.vexforum.com/t/vexcode-pid-tutorial/73706