How to display level score after completion of level in a separate scene ?

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

So I have made a 2D platformer game in which currently I have almost 4 stages and in each level the player can increase his score by collecting diamonds. The score gets increased with every diamond he collects and he can see his score on the top left corner of screen. But I want to make sure that when the level ends the player gets a screen where he sees his total score of that level and then continue to next level because right now the score becomes 0 when player advances to next level and the process begins again.

I use this in the player script :

func _on_Area2D_body_entered(body: Node) -> void:
var scoretext="Score : "+String(score)

where I get scorelabel using this :

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

I would use a “AutoLoad” script as a global class for the score variable:

juppi | 2020-06-12 14:28

:bust_in_silhouette: Reply From: pox

You can use Godot version of the Singleton pattern. Basically, you make a script available everywhere in the project and game, allowing you to store the score “globally”, it will persist in all scenes and scripts