0 votes

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
text(str(CurrentLap) +str(m)+":" +str(s)+":" +str(ms))
func onTimertimeout():
ms += 1
func _on
$LastLap.set_text(str(LastLap) +str(m)+":" +str(s)+":" +str(ms))
m = 0
s = 0
ms = 0

in Engine by (325 points)

2 Answers

0 votes
Best answer

Store the value in a Global variable.

See here

by (1,963 points)
selected by

Thanks deaton64!

0 votes

You can save all variables you want with this: https://godotengine.org/qa/44278/need-help-to-figure-out-how-to-sa

by (380 points)

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

Nice to hear that ;D

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.