Is the await keyword supossed to loop code in signals?

Godot Version

v4.3.stable.arch_linux

Question

I made a game in which when you kill an enemy it gives you one token, I added that functionality in the “died” signal like this:

tokens = 0

func _on_health_component_died() -> void:
	tokens += 1
	print(tokens)

	$Explosion_Particles.emitting = true

	await $Explosion_Particles.finished
	queue_free()

When I execute that code, the “tokens” variable doesn’t increment by one; it increments by 32, and the “print(tokens)” line is executed 32 times, too. I don’t know why it is looping, but I suspect it is because the “await” keyword loops over the code until its requirement is met.

Is there any way to make the code only run once, Thanks in advance

PD: I’m not an English speaker, I’m using Grammarly right now, I apologise for any misspelt word or confusing sentence

Await doesn’t loop into the code, this is something wrong with your code

Thanks. I discovered that the signal was being emitted repeatedly because it was in the health_component’s “_process()” function. Thanks for the help!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.