Like a laser. How do you rotate the part correctly?
COMMUNITY QUESTION
How do you connect a part from point A to B?
1 answer
We need a few observations.
The distance between
aandbcan be calculated as(a - b).magnitude, and this is the length of a part that stretches between them.The middle is given by their average:
(a + b) / 2The direction is given by pointing towards either
aorbfrom the middle. We can take advantage of theCFrame.new(from, lookingAt).
Thus, to connect a and b with a part:
local p = Instance.new("Part", workspace)
p.Anchored = true
p.FormFactor = "Custom"
p.Size = Vector3.new( 3, 1, (a - b).magnitude )
-- 3 is how wide
-- 1 is how tall
p.CFrame = CFrame.new( (a+b)/2, b )
This discussion is preserved as it was. New answers, comments, and votes are closed.
