Your parentheses don’t go around what they should. < target is outside of them. Move the closing ) from after the 2 until after target.
Separately:
500 ms is 0.5 s. That’s a long time to wait before checking again.
I’m assuming the last bit (-25s) is braking. Why would you keep braking before you get to your target? I think you want this outside and immediately following the while loop.
The function is going to end right after setting the braking. You might want to put a short delay in after those.
You’re passing your function a int called “wait,” but you’re not using it.