Ray returning nil when result should exist?

Hello!

I am currently working on creating some system that finds where two parts intersect. The problem is that when casting from a CFrame’s LookVector, it always returns nil and I am not sure why.

To help visualize:

Script:

    local p = Instance.new('Part') -- create pink part
	p.Parent = workspace
	p.CFrame = workspace.Part1.CFrame * CFrame.new(-4, 0, 0) 
	local i = workspace.IntersectPart -- part intersecting with green part
	local newCFrame = i.CFrame * CFrame.Angles(0, math.rad(90), 0) -- create new CFrame, CFrame of the green part
	
	local ray = workspace:Raycast(newCFrame.Position, newCFrame.LookVector)
	
	print(ray) -- nil
1 Like

Perhaps, try doing newCFrame.p + newCFrame.LookVector

1 Like

Thanks for the response. Which argument should that be?

1 Like

2# argument on the :RayCast() line.

2 Likes

Still returns nil unfortunately.

Edit: I had to do newCFrame.p * newCFrame.LookVector. Going to mark your answer as solution.

2 Likes