I think that you must not have the property named correctly. I would double check the spelling AND capitalization for the property that you are checking for. ClosestParent.blend (503 KB)
We’re encouraging you to stop asking for help and help yourself. How do you think we solve problems? The same way you can! Use print statements to write to the console and then compare what you expect to see with what you do
If you want the cube that runs the script to be the parent, then you need to change
own.setParent(closestObject)
To:
closestObject.setParent(own)
You may find this resource useful for any future projects. It is documentation for python specific to Blender. And like agoose77 said, it tends to be better to figure something out for yourself, however if you really do get stuck then there are many people that will be willing to help.