I appreciate the help you people give but I have the feeling people do not read it carefully. Or I am extremely bad at explaining.
Pikaguy, logically it makes no sense indeed to use such statements, but like I said the statement is not the issue here.
Thaws, I already tried that and I said that a local var does not work. If I take out the var and place it in @Initialize then it doesn't work either.
Like Thaws said in his 2nd point (which I repeated twice), the variabel needs to be a parameter and linked to the object Laser. Though how?!?!?!?
I looked at the code mroe closely and realised my mistake

using a parameter instead shouldn't be too hard though...
I never tried referring a task itself inside the task, but this should work.
//When creating a laser, enter 0 for the parameter of counter.task TReflectionLaser(x, y, v, angle, maxLen, width, graphic,
counter) {
// adjust the angle
while(angle >= 180) { angle -= 360; }
while(angle < -180) { angle += 360; }
// bullet object
let obj = Obj_Create(OBJ_LASER);
// initial settings
Obj_SetPosition (obj, x, y);
Obj_SetAngle (obj, angle);
ObjLaser_SetWidth (obj, width);
ObjShot_SetGraphic(obj, graphic);
ObjLaser_SetSource(obj, false);
TReflectionLaser_Lengthen(obj, maxLen, v);
TReflectionLaser_Move (obj, x, y, v, angle);
while(! Obj_BeDeleted(obj)) {
x = Obj_GetX(obj);
y = Obj_GetY(obj);
if(counter < *insert number of time you want it to bounce*) {
// reflection detection
if(angle < 0 && y < GetClipMinY) {
// ceil
TReflectionLaser(x, y, v, -angle, maxLen, width, graphic,
counter+1);
break;
} else if(((-90 < angle && angle < 90) && x > GetClipMaxX) ||
((angle < -90 || 90 < angle) && x < GetClipMinX))
{
// wall
TReflectionLaser(x, y, v, 180 - angle, maxLen, width, graphic,
counter+1);
break;
}
}
yield;
}
}