Difference In Studs (2 Points)

I’ve been looking this all over the place, haven’t found anything so far.

So basically what I’m trying to accomplish here is trying to get the amount of studs in between 2 points, in this case 2 parts.

Usually I would use magnitude for this, but this isn’t quite working for the result I’m trying to get. I made these images to show what I’m looking for, any help is appreciated!

The actual result I’m looking for.

The result that magnitude gives me, It returns the amount of studs from the center of the part. But that’s not what I want as shown in the image above

Thank you for stopping by an reading!

1 Like

Why not just scale down the part?

1 Like

I’m working on a system, that would required parts to be scaled to big sizes.

You could put an attachment in the part and position it to where you desire it to be.

``````local distance = (firstVector3 - Vector3.new(firstVector3.X, firstVector3.Y, secondVector3.Z)).magnitude
``````
1 Like

I’ve actually thought of that, but the thing is I would constantly need to position that attachment since the part was used for an example. In the real thing I’m using the player to check it [HumanoidRootPart] the player is constantly moving so wouldn’t be really efficient.

1 Like

Use raycast

Thank you, I’ll check this out.

Raycast is irrelevant in this case.

1 Like
``````local P1 = script.Parent.Part1
local P2 = script.Parent.Part2

while wait() do
local POS1 = P1.Position
local POS2 = P2.Position

print((POS1 - Vector3.new(POS1.X,POS1.Y,POS2.Z)).Magnitude)
end
``````

Update, I got a rough understanding how to accomplish this.
Thank you to @Pokemoncraft5290 Pokemoncraft5290