It would make sense if there was an issue here:
curPoint++
nextPointX = path_get_point_x(mypath,curPoint)
nextPointY = path_get_point_y(mypath,curPoint)
If you forgot any of these lines or had a typo in them this won't work
But yeah, debugging yourself or pasting your alarm code would help. The important parts are the values of curPoint, nextPointX and nextPointY
Alternatively, "speed" might be incorrect in the if statement, I think it should be path_speed, or possible something involving path_speed. I would try:
if (point_distance(x,y,nextPointX,nextPointY) <= path_speed) {
and just as a sanity check
if (point_distance(x,y,nextPointX,nextPointY) <= (path_speed + 5)) {