Semi-snap building system

So I want to script a building system.

I say “semi” because I’d like the first part to be placed out of snap, anywhere.

I would then like following pieces hovering nearby the placed structure to be snapped with the edges aligned. Even things like wall to ceiling or floor to wall.

If you’ve played Ark:SE, Rust, No Man’s Sky etc, it’s similar to those.

I did try following this but came out unsuccessful.

Cheers

I’d start with a using raycasting to find the first part’s location on the terrain or a Part or Parts named Baseplate, then after that check the raycastresult to see if you are placing it against a Part. If the raycastresult says you are placing it on Terrain or ‘BasePlate’ then don’t allow the placement.