0 votes

As Im working on a Game I got a problem I cant seem to set the text of a score counter by code, (which is a label), i heard theres a Set_text() but i have no idea how to use or even set the text with it.

Additional: how to make it add a speceific number, the like text is currently 0 but when a certain function loops, it will add ex: 10 or
if bla bla:
(text) += 10

Answers in both questions are appreciated.

asked Aug 26, 2019 in Engine by EnderCreeper1st (169 points)

1 Answer

0 votes

make a variable that is a number like:

var counter = 0

then you can change it freely, like:

counter += 10

and if you want to update the text label use:

YourLabel.text = str(counter)

YourLabel is of course your node and str function converts a number to string, which can be used with text fields.

Also, if you don't know how to get YourLabel handle, you can do this by two ways:




in both cases Godot should give you tips as you start writing.

answered Aug 26, 2019 by Skipperro (125 points)

Ahh its the str thats missing in my codes haha THANKS.

i'm trying to use this in

func _process(delta):
          ## when i click and spawn a circle in
          ballCountLabel.text = str(ballCount)

but then when i run it it says
and then trails off the screen? or maybe that's it, i dont know

Could you also provide the code showing what is ballCount?

I fixed it, nevermind. I stil have no idea why it showed "[Label:1187" though.

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.