Ok after about ten hours I got it working. Just for whoever is intrested.
I execute the script with trigger. To the triggers OnAct. field i write _null = [trigger1] execVM "lootspawn.sqf";
trigger1 is the name of the trigger. I use the name to clear the area of spawned loot when player leaves the area. Basicalli just added the code:
_mytrigger = _this select 0;
waitUntil { ( player distance _mytrigger ) > 30};
_objektid = nearestObjects [ _mytrigger , ["GroundWeaponHolder"], 50 ];
{deletevehicle _x} forEach ( _objektid );