i am having trouble with if statements.
this is my code.

func _input(event):
if myvariable: 1 <-- this has a STANDALONE EXPRESSION warning on it and i cant figure out why.
if event.is_action_pressed("spacebar"):
$label.text = "Good job."

i want the spacebar input to be sensed only when myvariable is 1.
it is sensing even is my variable = 0.

someone pls help!!

This is what you want:

func _input(event):
    if myvariable == 1:
        if event.is_action_pressed("spacebar"):
            $label.text = "Good job."

"1" by itself is an expression, not a statement.

In GDScript, the body of an "if" statement must be indented.

    can you help me with this too?
    this is my code:

    ` one_can_press = 1
    if one_can_press == 1:
    if event.is_action_pressed("1"): <-- if i press 1 it does not trigger.'

    You need to post your exact code.

    Place ~~~ on lines before and after the code.

    If there are any warning or error messages, state what they are, and which line(s) of code they reference.

    • Edited

    `func _input(event):
    if event.is_action_pressed("quit"): <---- this if statement is working
    get_tree().quit()

    if event.is_action_pressed("walk (sound)"):
    	$"walk sound".play
    
    
    if event.is_action_released("walk (sound)"):
    	$"walk sound".stop`

    (walk (sound) is the w, a, s, and d keys)

    the if statements say standalone expression. can you help me?

    You need to put parentheses after the .play and .stop to call the method.
    For example: $"walk sound".play()