Is it possible to change the transparency of label?

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

Hi, I’m new to GDscript and programming. Recently I was trying to do a text cloud which will slowly disappear. I created a scene which is a label node with a script attached to it.
The scene is spawned above the player whenever he “says” anything. Here goes the script:

 var alpha = 1
 
 func _process(delta):
    	alpha -= 0.001
        print("text")
    	set("custom_color/font_color",Color(1,1,1,alpha))

The text and font were set manually. The text isn’t changing, but the word “text” is being printed. I tried to use this code with RichTextLabel, but the result is the same. Have I failed to find the right method? Is it possible at all? Do I have to create shaders for this? (I’ve already suffered a lot please don’t make me do this)

:bust_in_silhouette: Reply From: volzhs

you can achieve by just using .modulate

var alpha = 1.0

func _process(delta):
    modulate.a -= 0.1 * delta

your_label.add_theme_color_override("font_color", Color(1, 1, 1, 1-delta))