How can I make a line from point to point

I wanna create a line from point to point or point to my player position, but i don’t know how can i create this. Any help?

Try using Beams.

Beam

2 Likes

If you want to use a BasePart to do this then the following function works great:

local function DrawLine(p, vec_1, vec_2)
	local m = (vec_1 - vec_2).Magnitude
	p.Size = Vector3.new(p.Size.X, p.Size.Y,  m)
	p.CFrame = CFrame.new(
		vec_1:Lerp(vec_2, 0.5),
		vec_2
	)
	return part
end

This function records the distance between the two vectors and places the part in the middle using Lerp. It also stretches the BasePart to extend its Z faces to touch the two points, thus creating the line.

This method would probably be best for detecting collisions with the line using .Touched or if you want to customize the line.

However, if you simply want a line then just use a Beam as suggested by @Agusta0002

2 Likes