How to check if a part is within another part's x and z

Im trying to make a tycoon, that you can build in your land, but if you try to build outside the land, it should not allow you to. also if the building part is rotated, it should check if all studs are in, depending on the size. I have tried and this is kinda my last hope, so I will be very thankful if anyone could help me with this issue. Thanks (: