Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to create a part between two points?

When I say between two points I mean two positions in the map, so the part wont 'fill in' but rather stretch from this position to this one. Is this possible?

Say for example:

pos1 = game.Workspace.Pos1.Value
pos2 = game.Workspace.Pos2.Value
part = Instance.new("Part")
--Part front at pos1 and back and pos2

3 comments

0

RayCasting.

0

Will look into it...

0

This is just a geometry problem if you want the part between two points in space that you already have the coordinates of. You only need raycasting if you have to first find points on the surfaces of irregular parts (parts like mesh or csg for which there is no simple calculation to get the surface points)

1 answer

✓ Accepted answer
local v = (pos1 - pos2)
part.CFrame = CFrame.new(pos2 + 0.5*v, pos1)
part.Size = Vector3.new(part.Size.X, part.Size.Y,v.Magnitude)

Note that because this uses the 2-vector CFrame constructor,you'll get an arbitrary part orientation if pos1 is almost directly above or below pos2, and you'll need to supply more information if you need the part oriented a particular way in this case.

This discussion is preserved as it was. New answers, comments, and votes are closed.