Randomize Scene

Before proceeding, please use the forum search feature at the top of the page to check if your question has already been answered.

How do I…

Make it so that whenever a button is pressed it chooses a randomized scene. If you press the button, it will pick at random a scene to put the player into. No other stuff for this topic because nothing is going wrong, I just want to figure out how to do this.

You could do this by making a number variable, and using a random number event from 1-amount of scenes you have, and coding it so that depending on the number the variable is that is where the player is sent.

There are a bunch of posts addressing this but I will rehash the most common solution (which is also what I use). If your scenes are all fairly different from each other, then rename your scenes to something like scene1, scene2, scene3, etc. Otherwise create multiple external layouts (you can still use the same naming convention (you will have to use something with numbers regardless)). Create a button and when it is clicked, run a change scene event with the argument as: “scene” + ToString(RandomInRange(0, 10)). Each time button is clicked a random scene will be loaded, obviously you can change the numbers to account for how many scenes you have. If you use a different naming convention just remember to concatenate the number and string properly. The same logic applies for extern layouts, use the load objects from external layout event with the same argument.