0 votes

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

in Engine by (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:

https://docs.godotengine.org/en/3.2/getting_started/scripting/gdscript/gdscript_basics.html#setters-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
by (380 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.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.