So you want the script to do things synchronized with the host transport?
The bad news is you can't do that exactly right now, it's coming, but it will only be available for new MSL scripts.
You can do something similar using Wait, but it can only wait for locations in the loop that is playing, not locations in the host transport. Since you're using host sync the loops are normally some number of host "bars". If you set the subcycles parameter to 4 (or whatever your time signature numerator is) then each subcycle will be the same size as one host beat. So the line:
Wait subcycle
will wait until the next subcycle in the loop, and then do the following line.
Whether this lines up properly with the host beats depends on how the loop was recorded. A cycle and subcycle can be thought of like a Bar and a Beat, but they're not always the same. If you have SyncUnit set to Bar, then when you sync record a loop, you should get one cycle for each host bar that elapses, and then the subcycles will subdivide that like beats. But if SyncUnit is set to Beat then each cycle represents one beat and you would have to deal with them differently. Almost everyone uses SyncUnit=Bar though.
So try inserting Wait subcycle in between script lines and see if that works for you.
It looks like you're using old MOS scripts, so it would look like this:
Wait subcycle
If you were using new MSL scripts, it's about the same but the W is not capitalized:
wait subcycle