Hi! I’ve been trying to figure out this problem for a while, and I can’t seem to figure out why my ray is going off to the left rather than on the other part across the way (see image). I’m trying to make it so it has a direct shot from Cam (The part that the ray is currently connected to.) to RaE (The part that isn’t connected to the ray.).
local Cam = game.Workspace:FindFirstChild("Cam")
local RaE = game.Workspace:FindFirstChild("RayPart")
while true do
--Ray ignore list.--
local RayIg = {workspace:FindFirstChild("Placed"), workspace:FindFirstChild("Cam"), workspace:FindFirstChild("RayPart")}
----------------------
--Create and commit ray.--
local raycast = Ray.new(Cam.Position, RaE.Position)
local part, pos = workspace:FindPartOnRayWithIgnoreList(raycast, RayIg, false, true)
--------------------------------
print(part, pos)
local distance = (Cam.Position - RaE.Position).magnitude
local pt = Instance.new("Part")
--Display Ray.--
pt.Position = pos
pt.Size = Vector3.new(1, 1, distance)
pt.Anchored = true
pt.Material = Enum.Material.Neon
pt.CFrame = CFrame.new(Cam.Position, pos) * CFrame.new(0, 0, -distance / 2)
pt.Parent = workspace
------------------
wait(5)
pt:Destroy()
end