Hello!
I’m no math genius so I am in a bit of need with this issue. Essentially, I am trying to create a basic gable roof, which is just 2 parts at a peak for right now. My problem is that there’s a small gap at the top and I am not sure how much bigger to make parts so it doesn’t happen.
Here’s my script, pretty basic. Feel free to try it out so you know what I’m talking about.
local partwidth0 = workspace.pw
local partwidth1 = workspace.pw2
local height = 1
local heightpart = Instance.new('Part', workspace)
heightpart.Position = (partwidth0.Position + partwidth1.Position) / 2
heightpart.Name = 'HEIGHT'
heightpart.Position = Vector3.new(heightpart.Position.X, heightpart.Position.Y + height, heightpart.Position.Z)
height = heightpart
local part = Instance.new('Part', workspace)
local dist = (partwidth0.Position - height.Position).Magnitude
part.Position = (partwidth0.Position + height.Position) / 2
part.CFrame = CFrame.lookAt(part.Position, height.Position)
part.Size = Vector3.new(part.Size.X, part.Size.Y, dist)
local part2 = Instance.new('Part', workspace)
local dist = (partwidth1.Position - height.Position).Magnitude
part2.Position = (partwidth1.Position + height.Position) / 2
part2.CFrame = CFrame.lookAt(part2.Position, height.Position)
part2.Size = Vector3.new(part2.Size.X, part2.Size.Y, dist)
height:Destroy()
Here’s my problem:
There’s a small gap in the top which gets more apparent as the roof height gets taller.
1 stud height:
10 stud height

100 stud height
I’ve tried writing a formula and this is what I came up with, but I was wondering if it was the most effective and accurate one:
length = magnitude + length + (16 / 360) * height

