How can i make a code for that?

Our aim is : stop the bar at the same point where it started after the turn.
But when we take one lap and stop, it is slipping.
I don’t know what to do as it slips on every lap.

I see the problem you have, but the only solution i can think of for that is to make it not go as fast, or make it stop earlier to account for the overshoot. so you stop it earlier so the overshoot gets you where you want.

Make sure you stop the turn at the right rotation (maybe use rotateTo) and maybe try using a break function

Turning on motor breaking will help reduce the overshoot, and a PID may help if that doesn’t.

you could also use a sensor such as a limit switch to stop the motor when it triggers at the desired point

Doesn’t spinFor() have rotation?