✓ Accepted answer
If you're getting the position using FindPartOnRay then presumably you have the ray itself. To get the direction of the ray you can simply access its Direction property:
local ray = Ray.new(...)
local direction = ray.Direction
You could then use this to construct a CFrame if you needed to. One way would be to use CFrame.fromMatrix:
local ray = Ray.new(start, endpoint-start)
local hit, pos, norm = game.Workspace:FindPartOnRay(ray)
local direction = ray.Direction
local lookVector = direction
local rightVector = direction:Cross(Vector3.new(0, 1, 0))
local upVector = rightVector:Cross(lookVector)
local rayCFrame = CFrame.FromMatrix(pos, rightVector, upVector)