How can i play a sound when a key is pressed?

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

This is my Code:

var speler =;

var first_time = true
var is_playing = false
func _physics_process(delta):
	if Input.is_action_just_pressed("primary_fire"):
		if  first_time:
			self.add_child(speler); = load("res://Sounds/GunShot.wav");
			first_time = false
		if not is_playing:;
			is_playing = true

Is something wrong? when i press the key its doesnt play a sound
The key input for “primary_fire” = Left Click

Pls help me

:bust_in_silhouette: Reply From: estebanmolca

I just tested your script and it works, check the file name well or try another, the folder is Sounds, sounds, sound !? My version is v3.3.2.stable.oficial