I have two vector3 points, and there is a part exactly positionned on the midpoint between them. The part is as long as the distance between the two points. How do I rotate it so it connects the two points?
So far what I've got
brick.Size=Vector3.new((tab[i]-tab[i+1]).magnitude,.2,0) brick.CFrame=CFrame.new(.5*tab[i+1]+.5*tab[i])*CFrame.Angles(0,math.pi,0) --Gotta change that math.pi for something appropriate
So, you have the Part positioned correctly, although admittedly with a method that hurts the look at. Anyways, you don't need to mess around with CFrame.Angles
. A much easier method is to use the CFrame.new(position, lookAt)
constructor.
Since the Part's already in the correct position, don't change that. But we can edit the second argument so that it will point towards the brick of your choice.
part.CFrame = CFrame.new(part.Position, workspace.Brick.Position) --Makes it face towards Brick.