Last/Best Lap times disappear at restart. How can I make it stay permanently?

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

I have “Track Record”, “Current Lap”, “Last Lap” and “Best Lap” labels. I got the Current Lap and Last Lap working correctly. But Last Lap (and Best Lap for that matter) gets back to zero once the level (or game) restarted. I need the Last Lap and Best Lap permanently stay there even after the game restarted. I would appreciate any solution you may suggest.

In case you need the script I have:

extends VBoxContainer
var CurrentLap = “Current Lap: "
var LastLap = “Last Lap: "
var BestLap = “Best Lap: "
var ms = 0
var s = 0
var m = 0
func _process(delta):
if ms > 9:
s += 1
ms = 0
if s > 59:
m += 1
s = 0
$CurrentLap.set_text(str(CurrentLap) +str(m)+”:” +str(s)+”:" +str(ms))
func _on_Timer_timeout():
ms += 1
func _on_finishline_area_entered(area):
$LastLap.set_text(str(LastLap) +str(m)+“:” +str(s)+“:” +str(ms))
m = 0
s = 0
ms = 0

:bust_in_silhouette: Reply From: deaton64

Store the value in a Global variable.

See here

Thanks deaton64!

Suleymanov | 2020-06-03 06:57

:bust_in_silhouette: Reply From: MaaaxiKing

You can save all variables you want with this:

You are my hero, MaaaxKing! Mega thanks! :smiley:

Suleymanov | 2020-06-07 13:16

Nice to hear that ;D

MaaaxiKing | 2020-06-07 13:28