Visualizing RayCast?

How would I visualize a RayCast? I’ve successfully learned how to use raycasting very basically, yet I don’t know how to visualize it yet. What I mean is, I’d like to actually see the ray, how would I do that? Here’s the code:

local start = script.Parent.Start

local fin = script.Parent.Finish

local rayorigin = start.Position

local raydest = fin.Position

local raydire = start.CFrame.LookVector*50

local ray = Ray.new(rayorigin,raydire)

local part = workspace:FindPartOnRay(ray, script.Parent)

print(part)

And where the script is located:

Screenshot_360

1 Like
3 Likes

Another option would be using a Beam that has one attachment positioned at the origin of the raycast and the second at the RaycastResult.Position.

8 Likes