Script Call for Showing Random Pictures every map change.

Hello!
I am working on a script to show a random image within a set of images everytime I go in a specific map.
The problem I have is that the script shows both the images I currently setup, instead of just one at a time.
I'm new to all of these, so maybe someone can check what I'm doing wrong?

Code:
let IMGIds=[2, 4,];
let IMGNames=["Pose1[5x15]", "Pose2[5x15]"];
let ranPick=[Math.randomInt(IMGIds.length)];
$gameScreen.showPicture(IMGIds[ranPick], IMGNames[ranPick], 1, 960, 580, 100, 100, 255, 0);

Currently, I only have two pictures that is setup. But I don't think that should matter right?
It's because you're using multiple picture ids. If you only want one picture to show, just use 1 all the time. It will replace the currently-showing picture with the one you want.

Where is the script - in a plugin, or in a script call? If it's in a script call, how is the event set up? Please show a screenshot of your event, with the full event window visible - don't crop anything away, I want to see how many tabs you have, all event commands, as well as the trigger (and maybe more).

You also have to erase the picture at some point as well - it won't just disappear when you leave the map.
It's because you're using multiple picture ids. If you only want one picture to show, just use 1 all the time. It will replace the currently-showing picture with the one you want.

Where is the script - in a plugin, or in a script call? If it's in a script call, how is the event set up? Please show a screenshot of your event, with the full event window visible - don't crop anything away, I want to see how many tabs you have, all event commands, as well as the trigger (and maybe more).

You also have to erase the picture at some point as well - it won't just disappear when you leave the map.

Oh I haven’t tried that ID thing, that actually makes a lot of sense.

My game is completely point and click, so the “map” is actually a parallax image that acts as a menu and the random image I am trying to randomize is the actor’s picture in different poses.

I believe to erase the image, I would just to put erase imageID# on the button events that I already setup to change maps.

I will provide everything after my work shift, thank you for replying!
I forgot to mention that I am also using Yanfly Picture Common Events, and the randomized picture is clickable.

But I’m afraid that if I have them all in 1 ID#, that means the plugin will always make the click run only 1 common event instead of different for each picture in the random selections.
then please show us a screenshot of the entire event instead of only the script
then please show us a screenshot of the entire event instead of only the script
It's because you're using multiple picture ids. If you only want one picture to show, just use 1 all the time. It will replace the currently-showing picture with the one you want.

Where is the script - in a plugin, or in a script call? If it's in a script call, how is the event set up? Please show a screenshot of your event, with the full event window visible - don't crop anything away, I want to see how many tabs you have, all event commands, as well as the trigger (and maybe more).

You also have to erase the picture at some point as well - it won't just disappear when you leave the map.


Attached are the relevant plugin, common event, and event pages.
I also showed a part of how it looks like when I run everything right now.
Notice that in the plugins, I haven't placed anything for Picture4 at the moment.

The goal is to have several images, not just 2, that will be randomly selected when I go in the map.
Only one will appear, and when clicked, will show a randomized text box as well.(this part works properly)

The problem is that it doesn't randomly call 1 image amongst the ones that are available to be chosen.
Instead, they stack on top of each other, as seen in the attached picture below.
I also tried using no scripts and got the same result.
UPDATE:

After much trial and error, I finally found a way.

I did it by making 3 individual events instead of 1.

1st event generates a variable randomly, the variable then turns on a switch, then erases the event.

2nd event is turned on by the 1st event, and has several pages depending on how many images total is in the array. The switch then generates the image associated with it.

3rd event is turned on via clicking the image generated by 2nd event. It calls a common event associated with it.

It all works perfectly now.
This can be closed.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/script-call-for-showing-random-pictures-every-map-change.157149/