So i'm working on a project were a ray is pointed and detects what it's on it's way. It's a straight line (theoretically to the infinity) and has amazing hardcoded functions that really helps me out with my project.
So far i got this:
local beam = game.workspace.Beam
local lookVector = beam.CFrame.lookVector
print(lookVector, " LookVector")
local direction = Vector3.new(0, 0, 100)
local ray = Ray.new(lookVector, direction)
print(ray, " (Start - Long)Ray")
local ray = Ray.new(
lookVector, -- origin
(direction - lookVector).unit * 500 -- direction
)
local hit, position, normal = game.workspace:FindPartOnRay(ray)
print(hit, " hit ")
if hit.Name == "Part" then
print("Part!")
else
print("No Part!")
end
The problem is that, even though "Part" is in front of the beam (on the z line) it says No Part! and the hit value equals Nil. I tested in all directions and still nil.
