Label is creating multiple text boxes

Godot Version

Godot Browser

Question

I am using label.text to change it so my label changes to a variable, and it is making multiple numbers in the same spot, How can I fix this? This is my code.

extends Node2D
var nothing : int = 0
var instantly_make_thing : bool = false
var which_last_selected : int = 1
var descension : int = 1
var descension_multiplier : int = 1
var nothing_maker : int = 0
var nothing_maker_maker : int = 0
var nothing_maker_maker_maker : int = 0

func _ready():
pass # Replace with function body.

Called every frame. ‘delta’ is the elapsed time since the previous frame.

func _process(delta):
pass

func _on_button_pressed():
nothing += (1 * (descension * descension_multiplier))

func _on_timer_timeout():
nothing += (1 * (descension_multiplier * descension_multiplier))
nothing_maker += (1 * (nothing_maker_maker))
nothing_maker_maker += (1 * nothing_maker_maker_maker)

func _on_nothing_maker_button_pressed():
if nothing >= 15:
nothing_maker += 1
which_last_selected = 2

func _on_nothing_maker_maker_button_pressed():
if nothing >= 1500:
nothing_maker_maker += 1
which_last_selected = 3

func _on_nothing_maker_maker_maker_button_pressed():
if nothing >= 15000000:
nothing_maker_maker_maker += 1
which_last_selected = 4

func _on_timer_2_timeout():
$nothing_count.text = nothing

Please always include a version number! It should be printed to the output window when launching your project.

You mean, like the numbers get drawn on top of each other? What number exactly did you expect to see? What number is shown instead?

The code you’ve shared should produce an error, since you’re trying to set the text property of your Label nothing_count with nothing which is of type int. You would need to manually convert it into a string first:

$nothing_count.text = str(nothing)

Other than that, there’s nothing in the code you have posted that would explain the behavior you described.

Yeah, sorry my version is 4.2.1, and yes it is multiple numbers on top of each other, and I tried making it a string and it didnt work.
I changed it to this
func _on_timer_2_timeout():
$nothing_count.text = str(nothing)
it works fine until i use this
func _on_button_pressed():
nothing += (1 * (descension * descension_multiplier))
image

So where does $nothing_count come from? Do you, by any chance, instantiate it somewhere in a script? Because, unless there’s multiple label instances at the same position, I don’t see any reason why this should happen (might be a bug, though).

The only place in the script it references $nothing_count is that one part.

So you created that Label node in advance, from the editor, before running the game? Have you checked the remote tree to see if there really is just one Label when you run the game and the error happens?