How to show Label text?

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

I have an InputEventMouseButtonwith a if statement in GDscript that once clicked, something shows. I want the Label text to pop up. I’m not sure if show()is the right solution, I want to toggle the visiblity of the text as soon as a button is clicked. How do I go about this?

Both of the answers worked, thank you very much!

DeafSavage | 2020-05-07 21:56

:bust_in_silhouette: Reply From: ArthyChaux

I would say you should connect your button to a function that shows it. So something like :

if not $Label.is_visible():

You just need to change $Label by the label path, and make sure it is hidden before, so either in the editor you hide it or you do

:bust_in_silhouette: Reply From: jgodfrey

As an example, create a new scene with the following node tree:


Now, wire the pressed signal of the Button to this script (stored on the CanvasLayer node in this case):

extends CanvasLayer

func _on_Button_pressed():
	$Label.visible = !$Label.visible

The label’s visibility will be “toggled” with each click of the button.