Floor is 10 studs across and walls are 1 stud thick, meaning that if you place two walls on either side of the floor, you will have 8 studs left over to place the remaining 3 walls.

You need to place a wall every 8/5 = 1.6 studs to maintain even spacing.

EDIT: Just kidding, my math is off. You need to place a wall every 10/8 studs, or 1.25 studs.

1.25 studs worked! But when I used it for other sizes, it stopped working.

As for your other note, I apologize for the lack of information. This is part of a script for a dynamic wall generation system. I just simplified it for the devforum post.

This hits close to home, but in my script, it already know the length of the pillar decided by a wall thickness variable. The spacing is the variable that is missing/needs improvement. Is this how I would change the formula for solve for spacing instead?

That’s the catch, the wall thickness can be anything. I’m basically handing a script to another person to edit so it must be ready for anything. This is why I’m trying to find the proper formula as shown in the above post.

You don’t take thickness into account, since you offset the first pillar by half its thickness into the floor. If we take the first and last part thickness into account, the equations are the following:

local thickness = 1
local amount = 5
local floorWidth = 10
local start = 0+thickness/2
local _end = floorWidth-thickness/2
--base of equation
local spacing = (_end-start)/amount
--basic maths, just for visualization
spacing = (floorWidth-thickness/2-(0+thickness/2))/amount
spacing = (floorWidth-thickness/2-0-thickness/2)/amount
spacing = (floorWidth-thickness/2*2)/amount
--derived equation
spacing = (floorWidth-thickness)/amount
print(spacing) --(10-1)/5 = 9/5 = 1.8

So after placing the first wall, you have to place the next one 1.8 studs after it.

The equation you should use is (floorWidth-thickness)/amount where floorWidth is the width of the floor below the parts, thickness is the part thickness(assuming it’s the same for all parts, else this equation doesn’t account for it) and amount is the number of parts to be placed on the floor. It will give you the offset/spacing of the next part compared to the one before it, starting from the part that is thickness/2 studs inside the floor part.

@TestAccount563344 I’m going to assume you didn’t account for the pillars themselves, which is why the ratio is too small. However, I am the person who asked the question.

@NyrionDev The ratio is a bit large (don’t mind the portion in the center)

What we know is that the correct ratio is 1.25, but only on a 10 by 10 grid where there are five pillars

In case I am just doing it wrong, here is the positioning line of code:

newwall.Position = Vector3.new(corner.Z + ((i2)*walllengthx), corner.Y + modulesize.Y/2, corner.X + (i1 * (9/5--[[this is where I plugged in your ratios]]))) + Vector3.new(newwall.Size.X/2,0 ,newwall.Size.Z/2) -- move to corner

i1 controls which wall out of 5
same goes for i2 but vice versa

What is the multiplication by i1? Is it some kind of sign?

Also, I assume the issue is that you add an extra newwall.Size.Z/2 to the final spacing due to the second Vector3 you add to the first one. So try modifying that to: Vector3.new(newwall.Size.X/2, 0, 0)

My assumption may be correct because 1.8-0.5 = 1.3 which is close to 1.25 and 0.5 is newwall.Size.Z/2(because in your post you say the thickness is 1).

Apologies for the late reply, I was trying to get some data and I was kind of busy. This is some data I collected for the correct number to multiply to get the right alignment

This is probably related to you adding extra offsets on top of my function output. However, I see a pattern here. When I remove my outputs from your outputs I get the following values:

2.25-1.8 = 0.45
4.75-3.8 = 0.95
9.75-7.8 = 1.95

When I increase the results by 0.05, the numbers become:

0.5, 1, 2

It’s obvious that when you duplicate the start value(for example from 10 to 20 or from 20 to 40) the resulting gap is also duplicated, however, the main issue is the extra offsets being applied.

I wish this topic could be over, but there is still a small issue. Normally, when I have the wallthickness at 1, it works correctly. But now if I change it to be bigger for example this happens: