What I did a while ago.
Make a main loop.
A variable that checks what level you are in, let's say -
Global Levelstatus as integer = 0
Do
If PlayerScore > 5000
Levelstatus = Levelstatus+1
Playerscore = 0
Endif
If levelstatus = 1 then gosub _BuildLevel1
If levelstatus = 2 then gosub _Buildlevel2
Sync
Loop
Apart from your "main loop" you can also make a loop in the gosub.
Rem - From the main loop we referred to the gosub _Buildlevel1
_Buildlevel1:
Do
Rem - Functions
Playerwalk()
Enemymovement()
etc.
Sync
Loop
Remember if you gosub to a new level, do not use the "return" command.
Keep in mind to unload everything you dont need and load everything you need for the second level.