scripts not effecting picture

hi! im new to rpg maker and i'm currently working on an event that starts, triggers another event, then starts a dialogue. the second event is a common event that contains a loop that iterates through an array displaying and erasing images depending on the value returned. however, when I use scripts to try to make changes to the picture nothing happens.
event 1:
1676334465972.png

event 2:
1676334100956.png

in the looping event i got around this by just using if statements, but now i want to stop the loop and erase the picture from the main event. as i want it to specifically erase whichever randomly selected image is currently dispalyed and the erase picture event command doesn't take a variable as input, I instead tried using a simple script to erase the picture using variable 3 (the one that decides which sprite is displayed).
1676334634625.png

this doesnt seem to work, however. any help would be awesome, thanks 🙂

Original thread: https://forums.rpgmakerweb.com/threads/scripts-not-effecting-picture.154951/