I don't know this kind of scripting. Maybe I'm completely wrong.
First of all this wasn't originally created for a building but for a character, was it? _dude?
Some variables are defined and never used?
_letpos, _dist, _posr
Other variables are used but aren't defined?
_statdist,
_pos probably fetched from the main script call?
Then there is this bracket open and I don't find a bracket closed for it:
[_x,_letpos,_dist] spawn {I don't understand why you would use a deletevehicle command on a map object.
Following to your topic title I would just use one simple line for everything:
_static = nearestobjects [_pos,["Building"], _dist]
{_x setdammage 1} foreach _staticPS:
You don't have to explain this script to me if it's just beyond my knowledge and I was writing crap.