✓ Accepted answer
I would measure the difference between coordinates on all three axes and set the size of the part to those three differences:
local pointOne = Vector3.new(24, 15, 10)
local pointTwo = Vector3.new(-15, 6, -42)
local x = math.abs(pointOne.X - pointTwo.X)
local y = math.abs(pointOne.Y - pointTwo.Y)
local z = math.abs(pointOne.Z - pointTwo.Z)
local part = Instance.new("Part")
part.Size = Vector3.new(x, y, z)
local connector = Instance.new("Part")
local distance = (pointOne - pointTwo).Magnitude
connector.Size = Vector3.new(1, 1, distance)
connector.CFrame = CFrame.new(pointOne, pointTwo) * CFrame.new(0, 0, -distance/2)
connector:Destroy()
part.Position = connector.Position
part.Parent = game.Workspace
The points are random but it should work.
I subtract pointTwo's coordinate from pointOne's and just call math.abs on it which returns the positive version, if it's negative, because we can't give our part a negative size.
I create the part, and size it.
To get its position, I create a part that is the length of the distance between the two points, and physically goes from point one to point two. After that, I just set the newly created part's position to the position of the connector. And it works.
1 comment
Thanks! I'll try it