Hey guys how would I go about adjusting p3 to stay in between point p1 and p2.
When I run the script p3 gets put onto p2 instead of stretching from p1 to p2
I hope that makes sense.
p1 = script.Parent.Part1 p2 = script.Parent.Part2 p3 = script.Parent.Part3 p3.Anchored = true p3.CanCollide = false length = (p1.Position - p2.Position).magnitude print(length) p3.CFrame = p1.CFrame +Vector3.new(length,0,0) function stretch(PointA,PointB) PointA.Size = PointA.Size +Vector3.new(length/2,0,0) end stretch(p1,p2)
If PointA is a part that you want to span from p1 to p2, use linear interpolation (lerp) and CFrame with 2 arguments.
PointA.Size=Vector3.new((p1.Position-p2.Position).magnitude,PointA.Size.Y,PointA.Size.Z) PointA.CFrame=CFrame.new(p1:lerp(p2,.5),p2)
p1:lerp(p2,.5) is .5 of the way from p1 to p2. From this position, the CFrame is set to look at p2.