How to create a wall linking system

I have made a wooden wall, that you can place in whatever orientation you want to create something like a base. However, it looks quite choppy when you place them. I want to make the wood walls link if they are close enough. Since the walls in the example below are close enough, I want to clone individual wall segments and put them in between the gap, in a straight line from the yellow wall pillars, since they are the ends of the wall. However, I don’t know how to do a few things:

  1. Get the positions to place them (do I just subtract the vector3 positions of each?

  2. How do I find the closest wall without looping through the entire workspace?

How do I find the closest wall without looping through the entire workspace?

Use GetPartBoundsInRadius to find nearby items and then loop through those to find the closest.

EDIT:

individual wall segments and put them in between the gap

What is a wall segment? Is it a single vertical “log” making up a few centimeters of fence or a longer set of logs making up like a meter of fence? If it’s the former, you can calculate how many there’s room for between the start and end and them space them evenly in the gap. If it’s the latter, there’s no good way of doing it unless the fence is placed in some kind of grid system so it doesn’t have to adjust the length.

To find the closest wall, you can use CollectionService to tag all your walls when they are created, and then iterate through the table to get the distances. Assuming all walls are perpendicular to the ground, you can use slope to get the orientation and then pivot it accordingly

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.