Are you getting any errors in the Godot console? Have you confirmed that the sound file exists at the given path? Finally, do you know whether the PlaySound
function is being successfully called from the first script?
I would suggest changing the PlaySound
function to the following:
func PlaySound(soundres):
var audioplayer = AudioStreamPlayer.new()
self.add_child(audioplayer)
print ("Audioplayer added to scene")
var sound_file_resource = load(soundres)
print ("Sound: ", sound_file_resource)
audioplayer.stream = sound_file_resource
audioplayer.play()
print ("Audio told to play \n")
With the code above, it may be easier to see what is going on thanks to the print statements.