# What ways could I achieve this

How would find the distance between a parts top and bottom.
Unlike finding the distance between two several parts. Iâ€™m only trying to find the distance between a parts top and bottom. I havenâ€™t tried any solutions yet because I donâ€™t think there currently is a method of finding the distance between a partâ€™s top and bottom.

1 Like

What if you made two points and just added/subtracted the partâ€™s size to it?

``````local top = part.Position + Vector3.new(0, part.Size.Y/2, 0)
local bottom = part.Position - Vector3.new(0, part.Size.Y/2, 0)

local dist = (top - bottom).Magnitude
``````
1 Like

Just an idea, but this might work:

``math.abs(part1.Position.Y - part2.Position.Y)``

Please read my first post carefully. To keep it simple Iâ€™m only using one part.

1 Like

when you say the distance from the top to the bottom, do you just mean the size of the partâ€™s Y?

1 Like

if the partâ€™s orientation is 0,0,0 then the part.Size.Y is the distance from the top of it to the bottom of it

1 Like

This works but only when the part is completely not rotated

You could try this script that gets the cframe positions of the top and bottom faces using the partâ€™s sizeâ€™s Y component

``````function FindDistBetweenTopAndBottom(Target: BasePart)
local Top = Target.CFrame:ToWorldSpace(CFrame.new(0,Target.Size.Y/2,0)).Position
local Bottom = Target.CFrame:ToWorldSpace(CFrame.new(0,-Target.Size.Y/2,0)).Position

return (Top - Bottom).Magnitude
end
``````

You can also use this function to get distance between left/right front/back faces by using x or z components

This is equivalent to `Part.Size.Y`. You just added half of Size.Y to itself `Size.Y/2 + Size.Y/2` which is equal to Size.Y.

There may be a better way to do this, but this is my solution. This function returns a Vector3 size. In your case, you would index the Y value to only get the height.

This is for only one part.

``````local function GetBoxSize(Part: BasePart): Vector3
local model = Instance.new("Model")
local clone = Instance.new("Part",model)
clone.Size = Part.Size
clone.CFrame = Part.CFrame
model.WorldPivot = CFrame.identity
return select(2,model:GetBoundingBox())
end
``````

This is for multiple parts

``````local function GetBoxSize(Parts: {BasePart}): Vector3
local model = Instance.new("Model")
for _, v in ipairs(Parts) do
local clone = Instance.new("Part",model)
clone.Size = v.Size
clone.CFrame = v.CFrame
end
model.WorldPivot = CFrame.identity
return select(2,model:GetBoundingBox())
end
``````

This reply is the equivalent of finding the parts size, which could be simply be done by doing:

``````local size =  p.Size
``````

All this is currently doing is finding the the parts y axis.

S = parts.Size.Y/2 is distance from center so pretty much you do (top = part.Position.Y +S) (bottom = part.Position.Y -S)

I donâ€™t think you know how this works.

1. First of all, it takes all parts into a model
2. Then it sets the modelâ€™s world pivot to `CFrame.identity` (Zero rotation, and Zero position)
3. Then it takes its Bounding Box (CFrame Pos, Vector3 Size)

Clearly you havenâ€™t tested my script, because I did, and I know that it works. It takes the size of a part in global rotation.

If you donâ€™t know about pivot, you can search about it. If you donâ€™t know about CFrame, you can search about it. If you donâ€™t know about the Bounding Box, it is just the size of a model.

And also, about the solution and the problem, the solution was taking the position of the parts top and bottom. But in your post you said â€śdistance between top and bottomâ€ť which is equal to `Part.Size.Y`.

Youâ€™re coming off as quite rude. The only thing is script does is fine the parts y. And I have tested that piece of waste you call code. I usually donâ€™t get frustrated about some dude criticizing my profession, and skills. The only reason I selected him as the solution was because every single post has been the same, including yours, the only difference was that you made it more complicated than it had to be. Iâ€™m sincerely sorry if this comes off as rude. .

Iâ€™m sorry if I was rude aswell. I understand what you are saying. Its just that I hate when people judge code without testing it first. I thought you did not test it so I got irritated, thus what I said was also affected.

I tested this, and I got close results. If it did not work for you, I will just post screenshots of me doing it and my code working.

You wanted a different solution anyways (and I misunderstood your problem) so letâ€™s not argue about my code not working.

I never so your code didnâ€™t work. And Iâ€™m personally sorry, if this offended you in way.