HOW TO GET END POSITION OF RAY FROM ViewPointToRay?

guys how to get vector3 position with origin and direction?
is this correct ?
rayPos = unitRay.Origin + unitRay.Direction * 5000
someone pls help

if UserInputService.TouchEnabled == true or UserInputService.KeyboardEnabled == false then
               

            local camera = workspace.CurrentCamera
            local viewportPoint = camera.ViewportSize / 2
            local unitRay = camera:ViewportPointToRay(viewportPoint.X, viewportPoint.Y, 0)
            local ray = workspace:Raycast(unitRay.Origin, unitRay.Direction * 5000)
            local rayPos
            if ray then
                rayPos = ray.Position
            else
                rayPos = unitRay.Origin + unitRay.Direction * 5000
            end
                CastRay(rayPos)
            else
            
            
                local P = Mouse.Hit.p
        
    
                CastRay(P)
        end

help rayPos = unitRay.Origin + unitRay.Direction * 5000 doesnt work