Getting position and normal without FindPartOnRayWithIgnoreList

Hello there! I noticed how the function FindPartOnRayWithIgnoreList is “deprecated” so I decided to convert one of my scripts with workspace:Raycast().

But one problem is with this line on the documentation

Contains the results of a raycast operation, or nil if no eligible BasePart or Terrain cell was hit.

So the position and normal wouldn’t be returned if there was no part. I would like to know a way to get these with a non-deprecated function.

Basically get something like this: instance=nil, position, normal

EDIT: I tried converting the other part of my script into raycast and it works perfectly, so I know how to do that case. My point is looking for position and normal in a ray.

Thanks!

1 Like

FindPartOnRay returned the Position correlating to the ray’s end if it never intersected. This would be the (Origin + Direction) and the Normal would always be 0.

Here’s one way you could emulate that with if-expressions:

local Result = workspace:Raycast(Oirigin, Direction, Params)

local Position = if Result then Result.Position else Origin + Direction
local Normal = if Result then Result.Normal else Vector3.zero
5 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.