MZ Javascript code help

I'm trying to show an image for one second but it doesn't work.

JavaScript:
$gameScreen.showPicture(1, "Bagee's sword", 1, 800, 500, 80, 80, 255, 0);
this.wait(60);
$gameScreen.erasePicture(1)

Am I doing something wrong?
This example can be done in an event without scripting, using the Show Picture, Wait, and Erase Picture commands. That might not apply for your situation, but I thought I'd mention it~

In a Script command in an event, this refers to the Game_Interpreter that is processing the event. this.wait sets that interpreter's wait counter. But the interpreter only checks its wait time between event commands. You can split the erasePicture call into a separate Script command, e.g.

◆Script:$gameScreen.showPicture(1, "Bagee's sword", 1, 800, 500, 80, 80, 255, 0); : :this.wait(60); ◆Script:$gameScreen.erasePicture(1);

If you are trying to do this in a different context (e.g. part of a plugin?) then you will need to give more details. For example, this is a keyword that refers to the current context: this.wait generally will not exist. If you want the interpreter to handle things in that situation then you'd also need to create appropriate event command objects and pass them to the appropriate interpreter, instead of simply calling functions.

Original thread: https://forums.rpgmakerweb.com/threads/javascript-code-help.138893/