It is probably hitting the op limit. Generating massive amounts of trackables in an area is very expensive. At the moment, given the input of 0 for pn, the outer loop will take 50 iterations to complete. The inner loop will take 60 iterations to complete. However, since it is a nested loop, the grand total will be 50*60 = 3000 iterations (a.k.a. 3000 trackables). It probably hits the op limit pretty quickly, too.
To fix it, you'll need to either: (1) reduce the number of iterations (2) run the actions on a separate thread (e.g. using ForForce(), TriggerEvaluate(), ExecuteFunc(), or whatever) (I recommend ForForce). Still, there might be a lag spike. To reduce the lag spike, change the Z field (where it says LOCATION_Z) to 0. Trackables don't specify a z-parameter, so it is actually done by generating a platform at that height before placing the trackable (and creating/removing a destructable is really slow). If the input is 0, my system will skip creating the destructable in general, and that can save a lot of performance.
Otherwise, just moving it to a separate thread should be fine. It might get a little laggy since starting a new thread is expensive, so you can always split it over time using a timer or something like that.