You want to have activated the ? Switch. Once you have, go into Big Boo's Haunt as Mario, and go to the room on the second floor with the ? Block. Break the block, pick up the flower, and fly up to the ledge above it. Then enter the Luigi painting and go through the level as normal.

Talk Doctor Online in Bissoy App