Raycast Result. Material not passing my If-statement?

Hi!

So I’ve stumbled upon a small issue, and a search on google and here on the forum didn’t quite give me the answer I was looking for.

I have raycasted, and the result I got was:

RaycastResult{Terrain @ 54.1537399, 17.486496, -71.8150635; normal = 0.00715642748, 0.955561578, -0.294704825; material = Grass}

But when I do my sanity check, to check if the material is grass, it won’t pass.

if RayResult.Material == "Grass" or RayResult.Material == Enum.Material.Grass then
	print("Grass was found")
end

Anyone know why this is the case? As you can see I tried both with and without Enum’.

Have you checked if RayResult is not nil?

Edit;

It works fine for me.
Screen Shot 2022-05-15 at 09.24.33

Output:
Screen Shot 2022-05-15 at 09.24.58

1 Like

Hi!

I’m glad you took the time to test it out!
I found out that the problem wasn’t with the material, but that I tried to check if the Rayresult.Instance was equal to “Terrain” instead of equal to workspace.Terrain. :slight_smile:

1 Like