stopp an audiostreamplayer after it played...

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By theMX89

im triying to make a shootsound, but if i press the shootbutton one time, the sound gets played infinitly. im using this code:

func _process(delta):
if Input.is_action_just_pressed(“shoot”):
$AudioStreamPlayer.play()

pass

what do i have to add to the script?

:bust_in_silhouette: Reply From: PunchablePlushie

Make sure your audio file is not set to be looped.

Select your audio file in the FileSystem dock. Then click on the Import tab (to the right-side of the Scene tab by default). Scroll down and make sure the “Loop” checkbox is not checked. Don’t forget to click on “Reimport” if you changed anything.

:bust_in_silhouette: Reply From: theMX89

thanks, it works. :slight_smile: