I tried running a Rhinoscript file on Rhino 4.0 and I get an error that MaterialId/MaterialIds is not a recognized method. I am wondering if there is a general incompatibility issue concerning Rhinoscript on Rhino 4.0?
if open V4 and go to help / plugins / rhinoscript, the rhinoscript helpfile opens. From there you can see which material methods are available.
Rhino.MaterialId() is not supported in V4.