Hello im trying to add icon that changes its texture similarly to the text in this dialogue system can someone help point me in the right direction on how to do this?

Here is the code

Text box code:
extends Node2D

@onready var richlabel = $tehtestxt/painel/teskbotainer/Tesktbokt/speaking
@onready var LDT = $tehtestxt/LDT
@onready var audio_player = $tehtestxt/AudioStreamPlayer

var text = “”
var aicon = “”
var letter_index = 0

var letter_time = 0.03
var space_time = 0.06
var punctuation_time = 0.2

signal finished_displaying()
#, icon_to_display: String
func displaying(text_to_display: String, talk_sfx: AudioStream):

audio_player.stream = talk_sfx

text = text_to_display
richlabel.text = text_to_display
richlabel.text = ""

_display_letter()

func _display_letter():
richlabel.text += text[letter_index]

letter_index += 1
if letter_index >= text.length():
	finished_displaying.emit()
	return

match text[letter_index]:
	"!",".",",","?":
		LDT.start(punctuation_time)
	" ":
		LDT.start(space_time)
	_:
		LDT.start(letter_time)
		
		var new_audio_player = audio_player.duplicate()
		get_tree().root.add_child(new_audio_player)
		new_audio_player.play()
		await new_audio_player.finished
		new_audio_player.queue_free()

func _unhandled_input(event):
if event.is_action_pressed(“unchoosen”):
letter_time = 0.0000001
space_time = 0.0000001
punctuation_time = 0.00000001

func _on_ldt_timeout():
_display_letter()

global script:

extends Node

#dialogue box scene
@onready var TBS = preload(“res://Scenes/UI Elements/dialogue_manager.tscn”)
#dialogue lines
var DL: Array[String] =
#current line index
var CLI = 0
var sfx:AudioStream
#textbox
var TB
#textboxposition
var TBp: Vector2
var dialogue_active = false
var can_advance = false

func start_dialogue(position: Vector2,lines:Array[String], talk_sfx:AudioStream):
if dialogue_active:
return
DL = lines
sfx = talk_sfx
TBp = position
#showtextbox
_STB()
dialogue_active = true

func _STB():
TB = TBS.instantiate()
TB.finished_displaying.connect(_on_text_box_finished_display)
get_tree().root.add_child(TB)
TB.global_position = TBp
TB.displaying(DL[CLI],sfx)
can_advance = false

func _on_text_box_finished_display():
can_advance = true

func _unhandled_input(event):
if (
event.is_action_pressed(“Choosen”) &&
dialogue_active &&
can_advance
):
TB.queue_free()
CLI += 1
if CLI >= DL.size():
dialogue_active = false
CLI = 0
return
_STB()

And this is how you call it:

extends Overworld

const lines: Array[String]= [
“hello”,
“this is a test”,
“how u doing”,
“yeah”,
]
@onready var talksound = preload(“res://wah.mp3”)

func _unhandled_input(event):
if event.is_action_pressed(“Choosen”):
Setting.start_dialogue(global_position, lines,talksound)