Rescale Model Based on Distance [ NEED HELP ]

Is there a way to make position and size of a part is based on a distance, so let’s say I have two points and the magnitude is 150, and I want to make a part that is between point A and B, uhm like a line, how to do it?

1 Like

You want to draw a line between two points?

local Part
local PointA,PointB

local Diff = PointB - PointA
local Magnitude = Diff.Magnitude

Part.Size = Vector3.new(0,0,Magnitude) -- Z is the "facing" direction we will be using
Part.CFrame = CFrame.new(PointA+Diff/2,PointB) -- A new CFrame, half-way to PointB, facing PointB

I can explain more of the math if you want

2 Likes

Why do the position is the opposite way?

1 Like


RobloxScreenShot20220417_191257549
RobloxScreenShot20220417_191318803
Look to the pictures why I said why the position is the opposite, I added with PathfindingService too , cause I want to make this for my Pathfinding system

1 Like

I need more context to help you. Can you show me your code, that’s producing this result?

1 Like

I will give it as soon as i’m on pc

1 Like