Problem in displaying score

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

I have a Gameplay scene where I have instanced Player scene that contains Player.gd script. The issue is that I have this function in my Player Script that is responsible for displaying score on screen :

func scoreDisplay():
	var scoretext = "Score : " + String(global.score)
	scorelabel.add_text(scoretext)

This is scorelabel where score is of type CanvasLayer and is child of Gameplay node which is my main scene :

onready var scorelabel = get_parent().get_node("Score/RichTextLabel")

The issue is that when I call this in the func _process(delta) or func _physics_process(delta) the score gets updated but every frame it stacks up and goes on forever without clearing the previous text on label. If I call this in func _ready()then the score never updates. I don’t know what the problem is. How can I fix the issue ?

:bust_in_silhouette: Reply From: klaas

Hi,
Add_text will add text.

scorelabel.text = scoretext

Will replace the text.

Thank you so much ! It works

Scavex | 2020-08-26 15:48