0 votes

I need to connect a variable with a label text. I used + for this, but it did not work. help me please

asked Jun 9 in Engine by Time of creat (12 points)

What's in the variable (a string, an integer, an object, ??). What was the result of your attempt? An error? If so, post the error text.

Also, posting the relevant code will help us better understand the issue...

1 Answer

0 votes

I leave you a bit of code which should help.
If you have doubts regarding the code, here is more info on setters and getters:


# with this setup, whenever you do self.labelText = "SOME_TEXT", 
# your label will update with that text. It'll also work if you
# set the labelText var from some other object/script

var labelText = "" setget setLabelText
onready var label = $Label

func setLabelText(text):
    labelText = text
    label.text = text
answered Jun 9 by jtarallo (376 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.