My UI sfx is not working properly (not consistent)

Godot version 3.6 beta

I am trying to add sound effect to my UI buttons but as I test something it play and something it don’t. I think because something before the sound fully played the scene changed that might be the problem but I don’t know how to solve this.

I am sharing you my codes and a example video below

Screenshot_2024-02-25-14-17-49-77_218127a443514d46ba847e5e6ae6a29b

Screenshot_2024-02-25-14-17-31-50_218127a443514d46ba847e5e6ae6a29b

and does it behave the same way even if you click slower? in the video the clicking is quite frenetic

Yes no matter how slow I click it behave in the same way

Your audio is getting cut-off because you are changing the scene so it’s getting deleted before it can finish playing the audio. There are multiple ways of fixing this:

1 Like

Which one is the best and effeciant way ? I think the autoload one is best because I can use that in other scenes too but still I don’t know how to implement it can you please explain it further

Am I getting any help ? Thank you

These aren’t working either

yes, @mrcdk mentioned it already… the sound you trigger is cleared by calling change_scene. the flood scene is erased and the sound is erased with it

and isn’t it useless to call a new scene every time in such a simple menu? it would be better for you to have one scene where you could simply hide and unhide given screens in the GUI. then the sound playback would not be a problem because you are always moving in one scene

or

instantiate the given scenes in a specific node in which you will also have the AudioStreamPlayer you will call

You mean all the scenes under one node and hide them all and just hide and unhide them when needed ?

1 Like

yes, it is one of the solution
for example I also have it like this

1 Like

Can I get any help one last time ?

pause menu script

extends Control
var is_paused = false setget set_is_paused
func _unhandled_input(event):
if event.is_action_pressed(“pause”): self.is_paused = !is_pausedfunc set_is_paused(value): is_paused = value get_tree().paused = is_paused visible = is_pausedfunc _on_Resume_pressed(): self.is_paused = falsefunc _on_Restart_pressed(): self.is_paused = false BackgroundLoad.load_scene(“res://GAME.tscn”)

game over menu script

extends Controlvar is_paused = false setget set_is_pausedfunc _on_End_body_entered(body): if body.is_in_group(“player”): self.is_paused = !is_pausedfunc set_is_paused(value): is_paused = value get_tree().paused = is_paused visible = is_pausedfunc _on_Restart0_pressed(): self.is_paused = false BackgroundLoad.load_scene(“res://GAME.tscn”)func _on_Quit0_pressed(): self.is_paused = false BackgroundLoad.load_scene(“res://HomeScreen.tscn”)

confirm you want to quit screen script

extends Controlvar is_paused = false setget set_is_pausedfunc _on_Quit_pressed(): visible = truefunc set_is_paused(value): is_paused = value get_tree().paused = is_paused visible = is_pausedfunc _on_Yes_pressed(): self.is_paused = false BackgroundLoad.load_scene(“res://HomeScreen.tscn”)func _on_No_pressed(): visible = false

these are my three script i want to combine these all and create one script that i can add to the root

Well if you have all your elements in one scene, and you disable/hide the buttons you don’t need (and change the text, essentially what the other comment said), then you can simply connect the buttons’ signals to one script that controls what is currently shown.