Using globals in await function

Godot Version

4.3

Question

im trying to use a global in an await function, but it is giving an error that says Only identifier, attribute access, and subscription access can be used as assignment target.

heres the code

func _on_touch_screen_button_pressed() → void:
Global.berry = true
await Global.berry = true
queue_free()

What you want to do with this code? Await a variable atribuition doesn’t make any sense.

im trying to make a hotbar system

Okay, but what you expeted to happen in this code?

it makes the object destroy its self, then it adds a berry to the hotbar

In this case you need to show your hotbar code, because if you just want to make Global.berry be true, the Global.berry = true is already enough, you can just call the queue_free() after. The await keyword is to await a signal be emmited before continue the code execution.

ohh ok thanks