0 votes

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 ?

in Projects by (359 points)

1 Answer

0 votes
Best answer

Hi,
Add_text will add text.

scorelabel.text = scoretext

Will replace the text.

by (2,436 points)
selected by

Thank you so much ! It works

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.

Categories