Allow ray to see through properties?
You are thinking of this backwards from how the ray sensor works. You want to look for "target" no mater what is in front of it.

Add a property to everything you want to get hit say "target". Then change the ray senor to look only for that property ("target") and enable X-Ray Mode.


Last your code can then look like this.

if ray.hitObject:
    target.worldPosition = ray.hitPosition


X-Ray Mode will let the ray look through everything, and the property will only return the objects with the property "target."