Is there a way to make somthing not repeat in Update?

What Wick Editor Version are you using?
1.9.3

Describe the Problem
I have a sorta console I am adding to my game. I want it so that when the ‘c’ key is pressed, it shows a promt() window where you can type commands. It works but the only problem is that even when it goes to the frame i want it too it brings back up the original prompt() window. Is there a way to make it only open once when i clicked a key?

What have you tried so far?
I wrote this!
if (key === "c" ) { var commandz = prompt('Command'); if(commandz=='basiccommand') { gotoAndStop(2); } }

That’s because your using “if(key==="c")” to see if the c key is pressed. Key is a built-in variable that is set to the last pressed key (so key will be set to “c” even after c is released). What you can do to have this not repeat is use this code instead:

if (isKeyJustPressed("c")) { 
var commandz = prompt('Command'); 
if(commandz==='basiccommand') { 
gotoAndStop(2); 
} 
}

Or, you can do this:

if (isKeyJustPressed("c")) { 
if(prompt('Command')==='basiccommand') { 
gotoAndStop(2); 
} 
}

Both ways work

1 Like

thank you!

1 Like

it is not working :/

i have no idea it is just doing nothing

Did you click “c,” then type “basiccommand” into the text box (the prompt(“Command”))?
(You can also use prompt("Command","basiccommand") )

If so, then the problem might be elsewhere in your code
(I opened a new project and tried the code I gave u, it seemed to work alright)

1 Like

the window is just not opening

Can u share a file?
I might be able to make it work

1 Like

oops i had it in ‘keyreleased’ instead of ‘update’
im sorry. thanks for the help!

1 Like