How to create a auto connecting road

So im making a city builder game i got all the placement done i only need it, if placing roads the roads connect let say u put 3 roads to the left and one up the third road will then curve around to the road that is up. I already got al the road prefabs only need the code. Hope u can help and i thank u in advance

Nvm i solved it i made 4 raycast in all direction and let them collide with a layermask if they collided with only 1 i check if it was left right front or behind if it from 2 sides i checked all possibilitys from 2 sides. Ect