I set up a very simple & generic raycast that will get the material and color of the Instance detected.
Printing the material seems to return a nil Instance value, but when the entire raycast is printed you can clearly see the material is a valid part of the ray.
Raycast
– RaycastResult{Model_Name @ 98.5538254, -0.259372652, -90.9927673; normal = 0.29143104, 0.88250792, -0.369109154; material = Neon}
Material (cap M doesn’t work either)
– ‘material’ is not a valid member of RaycastResult
Hm, you need to make sure it hits something so you can get the material at the intersection point. I would probably do…
if Raycast and Raycast.Instance then
print(Raycast.Material or "Couldn't find material.") -- This can vary depending on the terrain data, if it hits a terrain cell.
else
print("Didn't hit anything.")
end
Well, in fact, it must hit something so the raycasting results can return given properties instead of nil. That might be what is happening although I’d check just to make sure.