First check only for players, that is better than going through the creature names.
Use isPlayer(creature.uid)
Then create a local targetPos array {x,y,z} something like this:
local targetPos = {
x = square.exitpos.x + math.random(-8, 8),
y = square.exitpos.y + math.random(-8, 8),
z =...