I'm trying to make a module function that makes visual representations of rays. The problem is, I'm not all that great at CFrame/Vector3 positioning. Here's what I have:
function module.viewray(ray)
local part = Instance.new("Part", workspace)
part.Name = "Ray"
part.BrickColor = BrickColor.Red()
part.Transparency = .7
part.TopSurface = Enum.SurfaceType.Smooth
part.BottomSurface = Enum.SurfaceType.Smooth
part.CanCollide = false
part.Anchored = true
part.CFrame = CFrame.new(ray.Direction/2, ray.Direction) --Here I'm just guessing what I have to do
part.FormFactor = Enum.FormFactor.Custom
part.Size = Vector3.new(.2, .2, ray.Direction.magnitude) --Here too
end
And then I try to use that module function here:
viewray = require(game.ServerScriptService.Rays).viewray
origin = Vector3.new(0, 50, 0)
direction = Vector3.new(50, 50, 50) --Basically I'm trying to make a laser going across the sky
ray = Ray.new(origin, direction) --Guessing here too
viewray(ray)
And that creates a laser that doesn't go across the sky, but shoots from the center of the map to the sky. If someone could provide a brief walkthrough on rays, that would be great.

2 comments
...Still, It's a going up diagonally. I'm trying to get a completely horizontal line going across the sky.
The second parameter to
Ray.newis the direction (NOT the end-point). You told it to go up (the Y is 50). If you want it to stay level, that should have been (50, 0, 50)