Unable to run my script, error "x, band = band, objecttype = "RasterLayer"

It would be easier to help if you provided an minimal reproducible example: