Play sound after interacting with RichTextLabel

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

I want to play a sound after clicking on a RichTextLabel which shows the next dialog. All what I got is:

extends RichTextLabel

var dialog = ["Welcome to the game!", "Test"]
var page = 0


func _ready():
	set_bbcode(dialog[page])
	set_visible_characters(0)
	set_process_input(true)
	
	
func _input(event):
	if event.type == InputEvent.MOUSE_BUTTON && event.is_pressed():
		if get_visible_characters() > get_total_character_count():
			if page < dialog.size()-1:
				page += 1
				set_bbcode(dialog[page])
				set_visible_characters(0)
				get_tree().get_root().get_node("Control").get_node("SamplePlayer").play("Typing")
				if dialog.size() == get_total_character_count():
					 
get_tree().get_root().get_node("Control").get_node("SamplePlayer").stop_all()
				

func _on_Timer_timeout():
	set_visible_characters(get_visible_characters()+1)

The line which doesn’t work is line 22:

get_tree().get_root().get_node(“Control”).get_node(“SamplePlayer”).stop_all()

Instead of playing, the sound doesn’t play at all. Can anyone help me?

:bust_in_silhouette: Reply From: GameVisitor

Shouldn’t it be:

 .play() 

?

:bust_in_silhouette: Reply From: Christoffer

If you comment that line out and it works, the problem are in you’re if statement.