Create a global variable called "numberofthingschestcouldspawn" that represents the amount of objects the chest has to choose from, then give the chest the player walks to a number instance variable called "Thingtospawn" or something like that. Make the chests set that number to ceil(random(0,numberofthingschestcouldspawn)) every tick, meaning that the chest is constantly changing that instance variable to a random whole number in the ragne you want. Create an event on gamepad x pressed, and create subevents on that event for each possibility of that number (a subevent for chest Thingtospawn = 1, another subevent for chest Thingtospawn = 2, etc. etc.) and in those subevents have the chest spawn a singular item. That's how I would do it.