How to Make Raycast ignore Air and not ignore Water

local _, _, _, material = workspace:FindPartOnRayWithWhitelist(ray,{Enum.Material.Water})

So this is the raycast I have. I’m trying to make the ray detect water and not air. I tried making an ignore list with air, but it doesn’t work.

Both times, the error was ‘Unable to cast Value to Object’

Is there a way to make it ignore air? Or only detect water?

Side note, but I’d recommend using the workspace:Raycast() function instead

You’ll have to check for the Terrain Instance in the workspace, which should hopefully return back the Material it touched so you can detect if it touched Water or not

I’ve tried that. But it only returns air. And I need to make it ignore air because air is EVERYWHERE. :tired_face:
But yeh. I’ll switch to workspace:Raycast

Wait. I found the answer. Nvm guys.