Displaying intervals between Parts Touched

Hello, I am trying to create a script for a racing game I’m working on where there are three “Sections” and I want to create a ScreenGUI that displays how long it’s been since you hit the last checkpoint/section.

But I am unfortunately clueless and have no idea how to do something like this. I have created this image in an attempt to demonstrate what I am trying to achieve.


I’ve spent a while looking for anybody with a remotely similar problem on the DevForum and other websites but could find none.

Keep track of the time when the player first touches a checkpoint, and then every frame update the text label to show the current time, minus the last time they hit the checkpoint.

There are many ways to get the time. tick() is the simplest.

You could utilize a system such as this:

--code example
local last_touched = 0 -- the time (in seconds) the part was last touched
local stored_time = os.clock() -- the time (in seconds) that had passed since the UNIX Epoch at the time of the variable's declaration
local part_to_touch = <BasePart> -- the part to be touched

   last_touched = os.clock() - stored_time
   -- this subtracts the current time from the original stored time
   -- this could look like: 107.5 - 95
   -- the current time is the amount of seconds since the UNIX Epoch (Jan 1, 1970)

This only returns the amount of seconds however, you’d have to use string manipulation for minutes, hours, etc.