Problem with the Load Game button.

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

Guys, i am really in touble here.

After effort i succeeded to make a save system for my game.I store in a global variable called “bestscore” my best score. I have two scenes. One main scene called MENU with two buttons: one New Game button and one Load game button.The second scene called World and is the biggest part of my game.When i run the project we can see the MENU scene with the two buttons.When someone presses the New Game button then the game starts normally (World scene).I send a signal from New Game Node to MENU Node and in MENU script i have this:


func _on_NG_pressed():

var fortosi=load("res://World.tscn")
var ins=fortosi.instance()
visible= not visible

When the game starts we can see on the top and a score=0 (Label-child of the World scene).When i collect objects the score counts normally and the save system stores a best score.All right here.

Now,this is the problem.I want when someone presses the Load Game button then on the score (Label) to shows the bestscore.I wrote this in the Label script :


func _ready():

but with that way the bestscore is on Label independently if i press the New Game button or the Load Game button.Then, i created a Load Game button as a different scene , i merged it in World scene and i saved it as a scene in MENU scene.I sent a signal from Load Game node to Label node but obviously it was a solution to despair.Τhe Load Game button was on over the World scene and when i runned the project and i pressed the Load Game button obviously did nothing because it belonged to World scene.

Basically , i can start the game when i press the Load game button but the point is how the bestscore can may appear on the Label and starts the game from this score(bestscore). i realized that it is a very compicated situation…

Thank you in advance guys for any suggestion and i am sorry about my english.

I tried and this but nothing:

I sent a signal from Load Game node to MENU node and in MENUS’s script i wrote this:

func _on_LG_pressed():
var fortosi=load(“res://World.tscn”)
var ins=fortosi.instance()
visible= not visible
var node=get_tree().get_root().get_node(“/World/Label”)

I get this:

E 0:00:02:0164 Node not found: /World/Label
scene/main/node.cpp:1382 @ get_node() @ _on_LG_pressed()

Nick888 | 2019-06-02 07:02

I’m not sure I understand the question:

  • You can already start the game with “New Game” and with “Load Game”
  • You can already set the Label to the bestscore value in the ready function

If that’s true: Wouldn’t it be enough to just set bestscore to “0” in the new game function before creating the World instance?

Thomas Karcher | 2019-06-03 15:31

Thank you for your reply.
i just created a copy of World scene and i added there a new Label for the best score.Then, with the load button i open the copy World scene with the best score in this and problem solved . The point is that it took to me 7 days to find a solution for this…!

Thanks again.

Nick888 | 2019-06-04 16:31