I don't think the error is in your room function. I typed in your function and didn't get an error (although it would be a good idea to move the sprite definition code before the repeat loop. It seems unlikely you want to redefine it every frame).
My guess is you still have the while loop on about line 12 of your first screen shot causing problems. Can we see the code before the function call?
0そうだね プレイ済み