# Random generated text not working

I'm trying to make a game which requires a random generation of sentence upon pressing spacebar. I've never done anything like this and wanted to give it a shot with whatever knowledge I had.

Whenever spacebar is pressed, "Be something in something." appears. I want the somethings to be randomized.

This what I wrote in the Create event -

global.profession = irandom(2);
global.situation = irandom(2);


And this in the Space event -

draw_set_colour($777777); draw_set_font(fnt_rpl); if global.profession = 0{ global.profession = "a nurse" } if global.profession = 1{ global.profession = "a driver" } if global.profession = 2{ global.profession = "a police officer" } if global.situation = 0{ global.situation = "in a hospital." } if global.situation = 1{ global.situation = "in a car." } if global.situation = 2{ global.situation = "in a police station." } draw_text_ext_transformed(200, 500, "Be" + global.profession + global.situation, 20, 800, 1, 1, image_angle);  Room is set to be 1920x1080 and I've added the object in the room. I'm getting no result, not even an error, when I press space. • Are you placed this object in the room? – Dmi7ry Oct 17 '16 at 17:58 • BTW, All these randoms/ifs can be changed to next code: Create event: global.profession = choose("a nurse", "a driver, "a police officer"); global.situation = choose("in a hospital.", "in a car.", "in a police station");. And Draw event: draw_set_colour($777777); draw_set_font(fnt_rpl); draw_text_ext_transformed(200, 500, "Be " + global.profession + " " + global.situation + ".", 20, 800, 1, 1, image_angle);. And I not sure that you really need global variables (I don't know, maybe you used it somewhere else). – Dmi7ry Oct 17 '16 at 18:45
• @Dmi7ry thanks for your tip for reducing the lines of code. To answer your question, yes I had put the object in room. I realized that I wasn't using a Draw event and that's what caused the issue. As of now I've done Create and Draw even as per what you had mentioned and copy pasted Create events code to Space event. It did the job. Thanks again. – Swapnil Rastogi Oct 18 '16 at 14:42