What's the correct ratio pt. 2?

I am trying to correctly position studs in between each wall ( I know it looks weird but it is just simplified for the post). Right now it looks like this:

Notice how the studs are not aligned properly.

What’s the correct ratio to correctly position them to be in between each wall?

Here’s part 1 for a general idea of a similar solution.

Note that just like part 1, I want it to work for any size, thanks!

I seem to have forgotten the code, this is the current code. Note that this code handles 2 dimensions instead of one:

--corner: The starting corner of the foundation
--WallCounts: The Amount of walls there is spawning on each axis (X,Z)
for i2 = 0, script:GetAttribute("WallCounts").X -2 do
	for i3 = 0, script:GetAttribute("WallCounts").Y - 2 do
		local newpart = Instance.new("Part")
		newpart.Size = Vector3.new(1,1,1)
		newpart.Name = "Part"
		newpart.Anchored = true
		local multiplicative = (modulesize.X/20 - thickness * (0.05)) + (modulesize.X/5 - thickness * (0.2))
 --this multiplicative was the solution for part 1, but it is too small this time
		newpart.Position = Vector3.new(corner.X + i2 * multiplicative, 0, corner.Z + i3 * multiplicative) + Vector3.new(0,3,0) 
		newpart.Parent = newmodel
	end
end

Returning to this project, I found that this formula works exclusively for 5 walls going both ways and the parts appear to fit the best in a 25x25 - 30x30 module size:

Assume that nothing else has changed:

local multiplicativex = ((modulesize.X - modulesize.X * 0.2)/25--[[- thickness * (0.05)]]) + ((modulesize.X - modulesize.X * 0.2)/4 --[[- thickness * (0.2)]])
local multiplicativez = ((modulesize.Z - modulesize.Z* 0.2)/25--[[- thickness * (0.05)]]) + ((modulesize.Z - modulesize.Z * 0.2)/4 --[[- thickness * (0.2)]])
newpart.Position = Vector3.new(newX + i2 * multiplicativex, 0, newZ + i3 * multiplicativez) + v.SpawnOffset.Value + Vector3.new(newpart.Size.X/2,0 ,newpart.Size.Z/2)

I need it to work for all sizes and amounts