So I am making a feature where the best time in which the game is completed is saved, it saves the time and shows it correctly for the first time but second time its not, my script checks if the variable from previous save is greater than than the current variable and if the current variable is less than the saved one then it saves as the current best time, but its not working
Here my script is connected to component begin overlap and a sequence:-
The screenshot you posted is very blurry (low resolution) so I cannot see a whole lot. However, if I interpret things correctly, you check if a save-game exists and if that is the case you do another check to see if it is a new time. You then only save the current time if it is a new time, as the “ELSE”-path of your branch-node is not used. Consequently (if my previous interpretation is correct) you do not save new time-runs, if you already have a save.
Your script won’t work, because all (hour, minute and second) must be smaller than previous one.
Let say, the first record is 1 min 30 secs, the second record is 0 min 45 secs. The second record is faster, but the second is larger, it become false.
You must sum up hour and minute to second, ex:
2 min, 45 secs = (2 x 60) + 45 = 165 secs
1 min, 50 secs = (1 x 60) + 50 = 110 secs
The second record is faster, then save it.
Another solution, check if the hour is smaller, if yes then it is faster. Otherwise, check the minute, if it is smaller, then it is faster. Otherwise, check the second.
There is TimeSpan struct by engine, consider using it.